You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
623 B
23 lines
623 B
import json |
|
|
|
file_path = 'grafana/dashboards/dashboard.json' |
|
|
|
with open(file_path, 'r') as f: |
|
data = json.load(f) |
|
|
|
def fix_datasource(obj): |
|
if isinstance(obj, dict): |
|
if 'datasource' in obj and isinstance(obj['datasource'], dict): |
|
if obj['datasource'].get('type') == 'elasticsearch': |
|
obj['datasource'] = 'Elasticsearch' |
|
|
|
for key, value in obj.items(): |
|
fix_datasource(value) |
|
elif isinstance(obj, list): |
|
for item in obj: |
|
fix_datasource(item) |
|
|
|
fix_datasource(data) |
|
|
|
with open(file_path, 'w') as f: |
|
json.dump(data, f, indent=2)
|
|
|