grafana-wtf
grafana-wtf copied to clipboard
Datasources defined as variables listed as unused
First off, thank you for this incredibly useful tool!
In cases where a datasource is specified via variable, that datasource may appear as unused in the output of grafana-wtf explore datasources.
How to reproduce
- Add a new datasource in Grafana
- Create a dashboard in Grafana
- Add a variable of type "Data source" with an arbitrary name & confirm that the datasource created in step 1 can be selected
- Use the variable as the datasource for a new panel in this dashboard, confirm that the panel renders data from that source
- Run
grafana-wtf explore datasources
Expected
The unused field of the output does not contain the new datasource.
Actual
The unused field contains the new datasource.
Notes
Since a datasource variable of a given type with no filter could in theory match every datasource of that type, I'm not sure if there's an obvious fix that would avoid excluding too much from the unused field, for any Grafana instance that uses such datasource variables, which might itself be unexpected.
It might also be unexpected that the used field excludes datasources that can be selected via variable; though for the same reason as above, this might result in dashboards that use a datasource variable to appear in every used entry, which may itself be unexpected.
This might just be a documentation fix to warn that these cases exist. Or, perhaps a new argument could be added to explore datasources to control how to treat such cases?
Dear Ali,
thanks a stack for creating this issue.
This might just be a documentation fix to warn that these cases exist. Or, perhaps a new argument could be added to
explore datasourcesto control how to treat such cases?
I will be happy if grafana-wtf will be improved on this matter. However, I haven't wrapped my head about the issue yet. Would you also be up for submitting a corresponding patch?
With kind regards, Andreas.
Hi again,
I just found a minute to read a bit into the details of this issue.
In cases where a datasource is specified via variable, that datasource may appear as unused in the output of
grafana-wtf explore datasources.
Without doing too much research yet, I think the only option for providing a sane implementation would be that grafana-wtf should exercise the same functionality as Grafana here, essentially supporting the datasource is specified via variable feature, no?
The question which comes to mind, is: How could grafana-wtf resolve that variable into the effective data source name? Maybe using an API endpoint?
Maybe you can share some JSON payload snippets of dashboards which use that feature, in order to contribute to the implementation?
With kind regards, Andreas.
Dear Ali,
I've just submitted a corresponding patch at GH-60, aiming to improve the situation, at least for a specific case. What do you think about it?
This might just be a documentation fix to warn that these cases exist.
Good idea.
Or, perhaps a new argument could be added to explore datasources to control how to treat such cases?
I will be happy to listen to corresponding proposals.
With kind regards, Andreas.
Hi again,
have you been able to try out the new implementation? We will be happy to hear back if this improves the situation for you, and if you think we should take further actions on this topic.
With kind regards, Andreas.
Hi @amotl, apologies for the delay and thanks for the fix! This looks to address the issue.
Thanks again for building this great tool!
Hi Ali, thanks for reporting back!
Thanks again for building this great tool!
Thank you, appreciate it. [^1]
[^1]: Make sure not to miss the new GH-65 ;].