Dmitry Kuzminov
Dmitry Kuzminov

Reputation: 6584

How to define Grafana dashboard variable as a subset of another variable?

I have a variable in Grafana dashboard that allows multiple values. I need a subset of the values to use in the Repeat for box of Row options. To solve this problem I'm trying to create another variable that will select needed subset of values from the source one.

The source variable is of type Custom with Multi-value option selected. The Values separated by comma are, lets say, "A1, B1, A2, B2".

How to define an alias for this variable, that has the same values and the "Multi-value" property? The follow up question is how to define a variable that selects a subset of values (for example the values that start with "A")?

I'm using Grafana 8.1.3

Upvotes: 0

Views: 931

Answers (1)

alparius
alparius

Reputation: 60

This might be bit of a hack, and I'm not sure I fully understand your problem (your question could use better explained examples), but I think both cases can be solved by creating query-typed variables on your default datasource, but actually just querying your original variable.

  • In case of SQL, it is as simple as: SELECT '$myvar'. Not sure how it works with other query languages. And probably you can solve it from there.
  • Similarly, you can incorporate Grafana variables into other variables (for example in the where part to create dependencies between them).
  • Or you can hide variables if you don't want your users to interact with them, by not filling the Label field, and selecting to Hide the Variable.

Upvotes: 1

Related Questions