Generate local dashboard to avoid duplication
This commit is contained in:
@ -6,20 +6,50 @@
|
|||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 4:
|
||||||
print('Error: Dashboard or Channel not specified')
|
print('Error: Dashboard or Channel not specified')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
dashboard_json = sys.argv[1]
|
dashboard_json = sys.argv[1]
|
||||||
channel = sys.argv[2]
|
channel = sys.argv[2]
|
||||||
if channel not in ['edge', 'beta', 'stable']:
|
output_dashboard_json = sys.argv[3]
|
||||||
|
|
||||||
|
if channel not in ['edge', 'beta', 'stable', 'local']:
|
||||||
print('Error: Unknown channel:', channel)
|
print('Error: Unknown channel:', channel)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
with open(dashboard_json, 'r') as read_file:
|
with open(dashboard_json, 'r') as read_file:
|
||||||
data = json.load(read_file)
|
data = json.load(read_file)
|
||||||
|
|
||||||
if channel == 'stable':
|
if channel == 'local':
|
||||||
|
data['title'] = 'Local Testnet Monitor'
|
||||||
|
data['uid'] = 'local'
|
||||||
|
data['links'] = []
|
||||||
|
data['templating']['list'] = [{'current': {'text': '$datasource',
|
||||||
|
'value': '$datasource'},
|
||||||
|
'hide': 1,
|
||||||
|
'label': 'Data Source',
|
||||||
|
'name': 'datasource',
|
||||||
|
'options': [],
|
||||||
|
'query': 'influxdb',
|
||||||
|
'refresh': 1,
|
||||||
|
'regex': '',
|
||||||
|
'type': 'datasource'},
|
||||||
|
{'allValue': None,
|
||||||
|
'current': {'text': 'testnet',
|
||||||
|
'value': 'testnet'},
|
||||||
|
'hide': 1,
|
||||||
|
'includeAll': False,
|
||||||
|
'label': 'Testnet',
|
||||||
|
'multi': False,
|
||||||
|
'name': 'testnet',
|
||||||
|
'options': [{'selected': True,
|
||||||
|
'text': 'testnet',
|
||||||
|
'value': 'testnet'}],
|
||||||
|
'query': 'testnet',
|
||||||
|
'type': 'custom'}]
|
||||||
|
|
||||||
|
elif channel == 'stable':
|
||||||
# Stable dashboard only allows the user to select between the stable
|
# Stable dashboard only allows the user to select between the stable
|
||||||
# testnet databases
|
# testnet databases
|
||||||
data['title'] = 'Testnet Monitor'
|
data['title'] = 'Testnet Monitor'
|
||||||
@ -102,5 +132,5 @@ else:
|
|||||||
'type': 'query',
|
'type': 'query',
|
||||||
'useTags': False}]
|
'useTags': False}]
|
||||||
|
|
||||||
with open(dashboard_json, 'w') as write_file:
|
with open(output_dashboard_json, 'w') as write_file:
|
||||||
json.dump(data, write_file, indent=2)
|
json.dump(data, write_file, indent=2)
|
||||||
|
@ -38,7 +38,7 @@ fi
|
|||||||
|
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
./adjust-dashboard-for-channel.py "$DASHBOARD_JSON" "$CHANNEL"
|
./adjust-dashboard-for-channel.py "$DASHBOARD_JSON" "$CHANNEL" "$DASHBOARD_JSON".out
|
||||||
)
|
)
|
||||||
|
|
||||||
rm -rf venv
|
rm -rf venv
|
||||||
@ -65,7 +65,7 @@ echo --- Take a backup of existing dashboard if possible
|
|||||||
echo --- Publish $DASHBOARD_JSON to $DASHBOARD
|
echo --- Publish $DASHBOARD_JSON to $DASHBOARD
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
grafcli import $DASHBOARD_JSON remote/metrics
|
grafcli import "$DASHBOARD_JSON".out remote/metrics
|
||||||
)
|
)
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,11 @@ cd "$(dirname "$0")"
|
|||||||
|
|
||||||
set -x
|
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
|
||||||
|
|
||||||
: "${INFLUXDB_IMAGE:=influxdb:1.6}"
|
: "${INFLUXDB_IMAGE:=influxdb:1.6}"
|
||||||
: "${GRAFANA_IMAGE:=solanalabs/grafana:stable}"
|
: "${GRAFANA_IMAGE:=solanalabs/grafana:stable}"
|
||||||
: "${GRAFANA_IMAGE:=grafana/grafana:5.2.3}"
|
: "${GRAFANA_IMAGE:=grafana/grafana:5.2.3}"
|
||||||
|
Reference in New Issue
Block a user