Skip to content

Commit

Permalink
Merge pull request #8 from unfor19/bugfix-null-gnet-id
Browse files Browse the repository at this point in the history
Bugfix null gnet
  • Loading branch information
unfor19 committed Aug 31, 2020
2 parents 6bb426d + dbc3ac1 commit 7f9e860
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kubernetes/grafana/provisioning/dashboards/dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ providers:
allowUiUpdates: true
options:
path: /etc/grafana/provisioning/dashboards/node-exporter.json
- name: "Prometheus Overview 2.0"
- name: "Prometheus Overview 2.0" # Removed "gnetId": 3662 from prometheus-overview.json
orgId: 1
type: file
disableDeletion: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
},
"description": "Overview of metrics from Prometheus 2.0. \r\nUseful for using prometheus to monitor your prometheus.\r\nRevisions welcome!",
"editable": true,
"gnetId": 3662,
"graphTooltip": 0,
"id": 4,
"iteration": 1593254680849,
Expand Down
6 changes: 4 additions & 2 deletions scripts/grafana.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ def get_metrics_list(base_url, api_key):
api_key,
base_url
).json()
dashboard_name = dashboard_body['meta']['slug']
dashboard_gnetid = dashboard_body['dashboard']['gnetId'] if 'gnetId' in dashboard_body[
'meta'] and dashboard_body['meta']['gnetId'] else "null"
dashboard_name = dashboard_body['meta']['slug'] if 'slug' in dashboard_body[
'meta'] and dashboard_body['meta']['slug'] else "null"
print_msg(msg_content=f"Getting metrics from {dashboard_name}")
expressions = scrape_value_by_key(dashboard_body, "expr", str)
expressions += scrape_value_by_key(dashboard_body, "query", str)
Expand All @@ -105,7 +108,6 @@ def get_metrics_list(base_url, api_key):
if len(metric) > 5 and "/" not in metric:
dashboard_metrics.append(metric)
dashboard_metrics = sorted(list(set(dashboard_metrics)))
dashboard_gnetid = dashboard_body['dashboard']['gnetId']
data['dashboards'][dashboard_name] = dict()
data['dashboards'][dashboard_name]['metrics'] = dashboard_metrics
data['dashboards'][dashboard_name]['gnet_id'] = dashboard_gnetid
Expand Down

0 comments on commit 7f9e860

Please sign in to comment.