Skip to content

Retrieve entire Custom Variable list #192

Answered by ZuperZee
psheehymn asked this question in Q&A
Discussion options

You must be logged in to vote

You could use

htmlGraphics.getTemplateSrv().getVariables()

The getVariables() is a bit hidden, but here is the Grafana source code definition
https://github.com/grafana/grafana/blob/2c2ac096fe66df155b68f1578bfc1137e7af53e8/public/app/features/templating/template_srv.ts#L77
It just retrieves all the variables on the current dashboard.

I might be misinterpreting it, but below is a dashboard retrieving a value from somewhere. I retrieved it from the Grafana variables. The key is retrieved based on the value by retrieving all the Grafana variables and finding the key from the value.

{
  "__inputs": [],
  "__elements": {},
  "__requires": [
    {
      "type": "panel",
      "id": "gapit-html…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by psheehymn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants