Skip to content

Commit fd21eaf

Browse files
committed
Improve finding unused datasources
1 parent 8e20f78 commit fd21eaf

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ grafana-wtf changelog
55

66
in progress
77
===========
8+
- Improve finding unused datasources. Thanks, @meyerder.
89

910
2023-07-21 0.15.1
1011
=================

grafana_wtf/core.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ def explore_dashboards(self):
451451
# as well as dashboards to datasources and vice versa.
452452
ix = Indexer(engine=self)
453453

454+
# Those dashboard names or uids will be ignored.
455+
ignore_dashboards = ["-- Grafana --", "-- Mixed --", "grafana", "-- Dashboard --"]
456+
454457
# Compute list of exploration items, looking for dashboards with missing data sources.
455458
results = []
456459
for uid in sorted(ix.dashboard_by_uid):
@@ -460,7 +463,11 @@ def explore_dashboards(self):
460463
datasources_existing = []
461464
datasources_missing = []
462465
for datasource_item in datasource_items:
463-
if datasource_item.name in ["-- Grafana --", "-- Mixed --"]:
466+
if (
467+
datasource_item.name in ignore_dashboards
468+
or datasource_item.uid in ignore_dashboards
469+
or datasource_item.type == "grafana"
470+
):
464471
continue
465472
datasource_by_uid = ix.datasource_by_uid.get(datasource_item.uid)
466473
datasource_by_name = ix.datasource_by_name.get(datasource_item.name)

0 commit comments

Comments
 (0)