All/Multi-Value with key-value variables

  • What Grafana version and what operating system are you using?
    Grafana v7.4.5

  • What are you trying to achieve?

I have two variables that depends on each other.
v1 → x1
v2 → x2
v3 → x3

Instead of having two variables, I want to have only one, and to have two variables defined when I choose the first variable.

So I when choose v1 from the droplist, I’ll have two variables; v=v1 and x=x1 etc.

So I defined a custom variable with such value -

v1 : x1,v2 : x2,v3 : x3

And I’m using {v:text} or {v:value} to get the key/value in the queries.

The problem is with All/Multi-Value that doesn’t work.

All I get in such cases is the values but can’t get the keys concanted the same way.

(x1|x2|x3)

But I want also the have an option to get the keys too…

(v1|v2|v3)

Instead each place with ${v:text} is converted to All etc.

3 Likes

Hi @bityob, By any chance, did u figure out a way to achieve this?

same, for a query like:
sort_desc(sum(metric{label=~“${options:text}”}) by (version) )

Grafana is sending this to prometheus:
sort_desc(sum(metric{label=~“option1 + option2 + option3”}) by (version) )

instead of

sort_desc(sum(metric{label=~“option1|option2|option3”}) by (version) )

I found the solution to this!!!

So there are more than just :text and :value that you can append after the variable name.
What we are looking for here is the Pipe operator to be used when concatinating the results.

so you would access your values by entering: ${options:pipe}