Kaynağa Gözat

Inline metrics/scripts dependencies

Michael Vines 6 yıl önce
ebeveyn
işleme
470debef16

+ 0 - 1
.gitignore

@@ -2,7 +2,6 @@
 /book/src/img/
 /book/src/tests.ok
 /farf/
-/metrics/scripts/lib/
 /solana-release/
 solana-release.tar.bz2
 /target/

+ 4 - 3
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)

+ 3 - 3
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

+ 1 - 0
metrics/scripts/.gitignore

@@ -0,0 +1 @@
+/lib/

+ 2 - 3
metrics/adjust-dashboard-for-channel.py → 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)

+ 6 - 4
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=

+ 0 - 0
metrics/testnet-monitor.json → metrics/scripts/grafana-provisioning/dashboards/testnet-monitor.json


+ 2 - 4
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}"

+ 2 - 2
metrics/scripts/status.sh

@@ -26,7 +26,7 @@ cat <<EOF
 =========================================================================
 * Grafana dashboards are available at http://localhost:3000/dashboards
 
-* Enable local metric collection per shell by running the command:
-    source $PWD/enable.sh
+* Enable local metric collection per shell by running:
+    export SOLANA_METRICS_CONFIG="host=http://localhost:8086,db=testnet,u=write,p=write"
 
 EOF