Hi, our company’ grafana has several hundreds datasources. I’m not sure how many of them are being used (by dashboards/panels/variables). Are there any existing methods or tools which can help to find out unused datasources so that we can delete them ? Thanks !
Use GitHub - panodata/grafana-wtf: Grep through all Grafana entities in the spirit of git-wtf. and search datasource names. Or use Grafana API and search them in dashboard models (that’s what grafana wtf is doing )
Thank you, I will try it.
Would HashiCorp’s Consul work well for this? Maybe someone knows? I haven’t tried it yet but I hear it’s the go-to for service discoverability in the DevOps space. I’m hoping to be testing the service in the next 2 months. I’ll keep data sources in mind, so I can test if it can scan for these as well and integrate data source discoverability into Grafana.
thanks for sharing your needs and for mentioning
grafana-wtf in this context. With ,
grafana-wtf now has a corresponding feature and version 0.11.0 has just been released .
Finding out about unused data sources might now be as easy as
# Install program . pip install grafana-wtf # Set URL to Grafana. export GRAFANA_URL=https://grafana.example.org/ # Display all data sources and the dashboards using them, as well as unused data sources. grafana-wtf datasource-breakdown --format=yaml # Display names of unused datasources as a flat list. grafana-wtf datasource-breakdown --format=json | jq -r '.unused.datasource.name'
Let me know if this fits your bill already, if it will work flawlessly on a large Grafana instance, and if you think this feature could receive any further improvements. Thanks!
With kind regards,
 Add feature to display datasource breakdown by amotl · Pull Request #16 · panodata/grafana-wtf · GitHub
 Release 0.11.0 · panodata/grafana-wtf · GitHub
 We strongly recommend to use a Python virtualenv and/or the
pip install --user option to install the program, instead of installing it globally. In order to do so, you would invoke those commands beforehand:
python3 -m venv .venv source .venv/bin/activate pip install grafana-wtf
Thank you @amotl . I will try this tool next week when I back to work.
A few questions:
- After installation,
grafana-wtf --versionstill print 0.9.0 …
$ pip install grafana-wtf --upgrade py tmp at 20:54:58 Collecting grafana-wtf Using cached grafana-wtf-0.11.0.tar.gz (28 kB) Collecting six Using cached six-1.16.0-py2.py3-none-any.whl (11 kB) ... $ grafana-wtf --version grafana-wtf 0.9.0
- Have you considered about this scenario – data sources used in variables? Not checked out code yet.
Another feature request is to find out invalid data souces.
By invalid I mean the data source cannot pass test when press “Save & Test” button in its page.
I have written a tiny go script to do this. Maybe it can be added to grafana-wtf
thanks for reporting back your observations. I will go through each item one by one.
I can’t reproduce this within a fresh virtualenv on my workstation.
(.venv) sink:testdrive amo$ pip install grafana-wtf --upgrade (.venv) sink:testdrive amo$ grafana-wtf --version grafana-wtf 0.11.0
a) Are you also using a Python virtualenv for installing
b) Maybe you installed the new version into a virtualenv, but the system is still referring to a previous “global” installation? What does
which grafana-wtf say on your end?
Thanks for asking, I believe I did. The procedure collects data sources from the
I think the
templating slot is actually what we are usually referring to as
However, this section has to be improved, as just discovered and reported by @jangaraj at AttributeError: 'Munch' object has no attribute 'datasource' for datasource-breakdown · Issue #17 · panodata/grafana-wtf · GitHub.
Thank you for suggesting that, I’ve just created a dedicated issue to track this at Finding unhealthy data sources · Issue #19 · panodata/grafana-wtf · GitHub.
With kind regards,
grafana-wtf version 0.12.0 has just been released. The program is now also available as a container image, which might make its installation more effortless, see also How to run
grafana-wtf from container image.
Please note that regarding your feature request How to find unused data sources?, the corresponding subcommand has been renamed to
# Display all data sources and the dashboards using them, as well as unused data sources. grafana-wtf explore datasources --format=yaml # Display names of unused datasources as a flat list. grafana-wtf explore datasources --format=json | jq -r '.unused.datasource.name'
Other than this, two other subcommands have been added, namely
explore dashboards. I will be happy receive any feedback or requests about improvements to them.
With kind regards,
It turns out that the installation problem is caused by my operation mistake. It’s solved now.
Thank you for the work ! I will try this new feature today and give feedback.
Feedback: the command
grafana-wtf explore datasources --format=json | jq -r '.unused.datasource.name' works like a charm. It outputs the same result as my script in aspect of prometheus type data sources, and the log and work style are far better.