diff --git a/.gitignore b/.gitignore index 0b446606b1..c81ead1375 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ /book/src/img/ /book/src/tests.ok /farf/ -/metrics/scripts/lib/ /solana-release/ solana-release.tar.bz2 /target/ diff --git a/metrics/README.md b/metrics/README.md index 546f3949b0..5a99d74a2f 100644 --- a/metrics/README.md +++ b/metrics/README.md @@ -17,7 +17,8 @@ https://buildkite.com/solana-labs/publish-metrics-dashboard. ### Modifying a Dashboard -Dashboard updates are accomplished by modifying `metrics/testnet-monitor.json`, +Dashboard updates are accomplished by modifying +`metrics/scripts/grafana-provisioning/dashboards/testnet-monitor.json`, **manual edits made directly in Grafana will be overwritten**. * Check out metrics to add at https://metrics.solana.com:8888/ in the data explorer. @@ -31,13 +32,13 @@ Dashboard updates are accomplished by modifying `metrics/testnet-monitor.json`, `Settings` menu for the dashboard 3. Edit dashboard as desired 4. Extract the JSON Model by selecting `JSON Model` in the `Settings` menu. Copy the JSON to the clipboard - and paste into `metrics/testnet-monitor.json` + and paste into `metrics/scripts/grafana-provisioning/dashboards/testnet-monitor.json`, 5. Delete your development dashboard: `Settings` => `Delete` ### Deploying a Dashboard Manually If you need to immediately deploy a dashboard using the contents of -`metrics/testnet-monitor.json` in your local workspace, +`testnet-monitor.json` in your local workspace, ``` $ export GRAFANA_API_TOKEN="an API key from https://metrics.solana.com:3000/org/apikeys" $ metrics/publish-metrics-dashboard.sh (edge|beta|stable) diff --git a/metrics/publish-metrics-dashboard.sh b/metrics/publish-metrics-dashboard.sh index 4527469dc3..3cfa107773 100755 --- a/metrics/publish-metrics-dashboard.sh +++ b/metrics/publish-metrics-dashboard.sh @@ -31,14 +31,14 @@ if [[ -z $GRAFANA_API_TOKEN ]]; then exit 1 fi -DASHBOARD_JSON=./testnet-monitor.json +DASHBOARD_JSON=scripts/grafana-provisioning/dashboards/testnet-monitor.json if [[ ! -r $DASHBOARD_JSON ]]; then echo Error: $DASHBOARD_JSON not found fi ( set -x - ./adjust-dashboard-for-channel.py "$DASHBOARD_JSON" "$CHANNEL" "$DASHBOARD_JSON".out + scripts/adjust-dashboard-for-channel.py "$DASHBOARD_JSON" "$CHANNEL" ) rm -rf venv @@ -65,7 +65,7 @@ echo --- Take a backup of existing dashboard if possible echo --- Publish $DASHBOARD_JSON to $DASHBOARD ( set -x - grafcli import "$DASHBOARD_JSON".out remote/metrics + grafcli import "$DASHBOARD_JSON" remote/metrics ) exit 0 diff --git a/metrics/scripts/.gitignore b/metrics/scripts/.gitignore new file mode 100644 index 0000000000..12c18d4ede --- /dev/null +++ b/metrics/scripts/.gitignore @@ -0,0 +1 @@ +/lib/ diff --git a/metrics/adjust-dashboard-for-channel.py b/metrics/scripts/adjust-dashboard-for-channel.py similarity index 98% rename from metrics/adjust-dashboard-for-channel.py rename to metrics/scripts/adjust-dashboard-for-channel.py index ba7155cfca..e802e409fd 100755 --- a/metrics/adjust-dashboard-for-channel.py +++ b/metrics/scripts/adjust-dashboard-for-channel.py @@ -6,13 +6,12 @@ import sys import json -if len(sys.argv) != 4: +if len(sys.argv) != 3: print('Error: Dashboard or Channel not specified') sys.exit(1) dashboard_json = sys.argv[1] channel = sys.argv[2] -output_dashboard_json = sys.argv[3] if channel not in ['edge', 'beta', 'stable', 'local']: print('Error: Unknown channel:', channel) @@ -132,5 +131,5 @@ else: 'type': 'query', 'useTags': False}] -with open(output_dashboard_json, 'w') as write_file: +with open(dashboard_json, 'w') as write_file: json.dump(data, write_file, indent=2) diff --git a/metrics/scripts/enable.sh b/metrics/scripts/enable.sh index 2989089c74..b18691e33c 100644 --- a/metrics/scripts/enable.sh +++ b/metrics/scripts/enable.sh @@ -2,7 +2,9 @@ export SOLANA_METRICS_CONFIG="host=http://localhost:8086,db=testnet,u=write,p=write" -# shellcheck source=scripts/configure-metrics.sh -source "$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. || exit 1; pwd)"/scripts/configure-metrics.sh - -echo Local metrics enabled +__configure_metrics_sh="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. || true; pwd)"/scripts/configure-metrics.sh +if [[ -f $__configure_metrics_sh ]]; then + # shellcheck source=scripts/configure-metrics.sh + source "$__configure_metrics_sh" +fi +__configure_metrics_sh= diff --git a/metrics/testnet-monitor.json b/metrics/scripts/grafana-provisioning/dashboards/testnet-monitor.json similarity index 100% rename from metrics/testnet-monitor.json rename to metrics/scripts/grafana-provisioning/dashboards/testnet-monitor.json diff --git a/metrics/scripts/start.sh b/metrics/scripts/start.sh index ff28578718..5cfb8a979e 100755 --- a/metrics/scripts/start.sh +++ b/metrics/scripts/start.sh @@ -11,10 +11,8 @@ cd "$(dirname "$0")" set -x -if [[ ! -f grafana-provisioning/dashboards/local.json ]]; then - ../adjust-dashboard-for-channel.py \ - ../testnet-monitor.json local grafana-provisioning/dashboards/local.json -fi +./adjust-dashboard-for-channel.py \ + grafana-provisioning/dashboards/testnet-monitor.json local : "${INFLUXDB_IMAGE:=influxdb:1.6}" : "${GRAFANA_IMAGE:=solanalabs/grafana:stable}" diff --git a/metrics/scripts/status.sh b/metrics/scripts/status.sh index c48b0c28a5..1166c9064b 100755 --- a/metrics/scripts/status.sh +++ b/metrics/scripts/status.sh @@ -26,7 +26,7 @@ cat <