Skip to content

Commit

Permalink
Improve finding unused datasources
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Jul 30, 2023
1 parent 8e20f78 commit fd21eaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ grafana-wtf changelog

in progress
===========
- Improve finding unused datasources. Thanks, @meyerder.

2023-07-21 0.15.1
=================
Expand Down
9 changes: 8 additions & 1 deletion grafana_wtf/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ def explore_dashboards(self):
# as well as dashboards to datasources and vice versa.
ix = Indexer(engine=self)

# Those dashboard names or uids will be ignored.
ignore_dashboards = ["-- Grafana --", "-- Mixed --", "grafana", "-- Dashboard --"]

# Compute list of exploration items, looking for dashboards with missing data sources.
results = []
for uid in sorted(ix.dashboard_by_uid):
Expand All @@ -460,7 +463,11 @@ def explore_dashboards(self):
datasources_existing = []
datasources_missing = []
for datasource_item in datasource_items:
if datasource_item.name in ["-- Grafana --", "-- Mixed --"]:
if (
datasource_item.name in ignore_dashboards
or datasource_item.uid in ignore_dashboards
or datasource_item.type == "grafana"
):
continue
datasource_by_uid = ix.datasource_by_uid.get(datasource_item.uid)
datasource_by_name = ix.datasource_by_name.get(datasource_item.name)
Expand Down

0 comments on commit fd21eaf

Please sign in to comment.