Reputation: 58
I have a custom variable in grafana $var
, which has values ["option1", "option2", "option3"]
. I would like to have another custom (hidden) variable $auxvar
where the value is entirely dependent on the value of $var
, e.g.:
"option1" -> "auxvar_option1"
"option2" -> "auxvar_option2"
"option3" -> "auxvar_option3"
Because the value of $auxvar
is entirely dependent on $var
, I want the user to be able to select the value of $var
and have $auxvar
set automatically (without the user's knowledge). I currently just have two custom variables $var
and $auxvar
, where the user must set both, but this is a somewhat hacky workaround. It seems like chained variables are almost related here, but they don't quite fit my use case. I'm wondering if there's some obvious way to do this that I'm missing.
Edit: realize this is ambiguous. I should clarify that $auxvar
is not directly related to the content of $var
as the above implies. It's more like this:
label1 -> label2="blah2", label3="blah3"
label2 -> label1="blah1", label3="blah3"
label3 -> label1="blah1", label2="blah2"
I basically have a query that averages by $var
, but based on the selection of that label, I want to limit the result set using $auxvar
.
Upvotes: 1
Views: 3721
Reputation: 22311
You can use key/value variables like the following example:
Type = Custom
Values separated by comma = var1 : auxvar1,var2 : auxvar2, var3 : auxvar3
The user will just see one picklist:
But you'll have the key and the value available in your panels, for example, suppose the user select "var1":
${var:text} = var1
${var:value} = auxvar1
Upvotes: 2