Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve finding unused datasources #78

Merged
merged 1 commit into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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