We are making changes to some of our datasources and are looking for a way to find all dashboards using these datasources. Is there a way to list all dashbaords using a datasource?
I don’t think there’s an “off-the-shelf” way. You’d probably need to iterate through each of the dashboard definitions and check whether any panels (or template variables) use that datasource. To do that you could either:
a) Write a script that pulls each dashboard’s JSON definition via the API and does a text search for the datasource name. (probably the “right” way to do this, but requires some effort)
b) Run a SQL query to search the Grafana database. You’d need to search through the data
column of the dashboard
table. (probably the quicker way, provided you have direct access to the DB)
If you’re using the (default) SQLite Grafana database, you could also open up grafana.db in a visual explorer (like https://sqlitebrowser.org) and quickly filter the dashboard definitions with that.
Dear Nayana,
Introduction
On https://weather.hiveeyes.org/, we regularly are facing the same requirements.
As pointed out by @svetb, Grafana itself doesn’t offer such a feature, but we implemented GitHub - panodata/grafana-wtf: Grep through all Grafana entities in the spirit of git-wtf. the other day, which exactly does
Details
We already wrote some more about this at:
- https://localhost:3000/t/use-grafana-wtf-to-search-through-all-entities-of-a-grafana-instance/13828
- https://localhost:3000/t/how-can-i-search-for-a-dashboard-by-content-e-g-name-of-panel-used-metric-used-function/5129
We will be happy to hear about whether this was helpful to you. Please let us know if you need further assistance with grafana-wtf
.
With kind regards,
Andreas.
This looks useful, we will give this a try and see how it works for us. WIll get back here to let you know how it went, Thanks
This tool is great and has helped me a lot
Hi again,
Coming from a discussion with @chenlujjj and @jangaraj at https://localhost:3000/t/how-to-find-out-unused-datasources/56920, we recently added a few new features to grafana-wtf
. One of them is explore dashboards
, which might fit very well in this context.
To make the story short, those two command invocations, combined with jq
, can aid in helping to find dashboards using specific data sources, either by name or by type.
# Display all dashboards which use a specific data source, filtered by data source name.
grafana-wtf explore dashboards --format=json | jq 'select( .[] | .datasources | .[].name=="<datasource_name>" )'
# Display all dashboards using data sources with a specific type. Here: InfluxDB.
grafana-wtf explore dashboards --format=json | jq 'select( .[] | .datasources | .[].type=="influxdb" )'
With kind regards,
Andreas.