grafonnet
grafonnet copied to clipboard
Populating and setting a variable's current value
Hi and thanks for the work on making grafonnet better aligned with the development of Grafana!
I have been playing around with the 10.2.0 API and Grafana 10.2.3 and now have the following variable definition:
{
abc:
var.custom.new('abc', values=['true', 'false', 'limited'])
+ var.custom.generalOptions.withLabel('Abc?')
+ var.custom.generalOptions.withCurrent('false')
+ var.custom.selectionOptions.withMulti(false)
+ var.custom.selectionOptions.withIncludeAll()
}
However, the variable's current value remains "true" despite the withCurrent('false'). How do I influence the variable's current (default) value?
Also, how do I make the default value "All"?
And finally, query type variables do not seem to populate as expected. After uploading a dashboard definition including the use of query variables, I need to manually go and click Run query in the Grafana variable editor UI to populate values.
Here is the output I see when executing that, can you say what you are referring to specifically?
{
"abc": {
"current": {
"selected": false,
"text": [
"false"
],
"value": [
"false"
]
},
"includeAll": true,
"label": "Abc?",
"multi": false,
"name": "abc",
"options": [
{
"selected": true,
"text": "true",
"value": "true"
},
{
"selected": false,
"text": "false",
"value": "false"
},
{
"selected": false,
"text": "limited",
"value": "limited"
}
],
"query": "true : true,false : false,limited : limited",
"type": "custom"
}
}
Have you run this in Grafana and was that not working as expected, how did it behave?
Also, how do I make the default value "All"?
It looks like that has changed since the inception of the code that supports this. I've made an issue for this: https://github.com/grafana/grafonnet/issues/166
And finally,
querytype variables do not seem to populate as expected. After uploading a dashboard definition including the use ofqueryvariables, I need to manually go and clickRun queryin the Grafana variable editor UI to populate values.
Can you create a separate issue with examples? We've tried to cover for this in the past so examples might help identify what's causing this.