GrafanaJsonDatasource: Can't assign a variable to the Metric field
Hi @simPod,
I think I bumped into the issue in v0.2.4, a fresh version (also in v0.2.3).
The metric value, which I want to assign to the variable (e.g. $project) once typed in, gets evaluated, disappears and then the empty value (“”) being passed to the subsequent API. The variable is resolved and the first request actually returns the result, but then it’s superseded by the empty string almost immediately.

I was able to apply the workaround, by manually passing $project to the JSON and saving it via Query Inspector. This works well, unless someone opens panel settings. It then gets reevaluated immediately to empty string again.
I’ll probably handle empty string case differently for now (currently it’s a valid target, so it returns all the results and it’s quite a large dataset) to avoid issues.
But overall it be great if the created value for the metric would be stored in the field. I’m happy to provide any info, also can look into the issue myself. Just wanted to share the info.
Gif attached. Grafana version: v7.4.3
Thanks!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 23 (2 by maintainers)
Hey @simPod, just a quick update from my side: I’ve managed to fix the issue I had. Still there is a small thing to improve before submitting it as a PR. 😃👍
@burningalchemist Thanks a lot! The workaround works well for us. Looking forward for your PR. 👍
Interesting usecase, did not know it might even work like this. I guess it’s valid, should be handled. Care to look into it?