'How to use Grafana dashboard variable in another variables regex?
I created a Grafana dashboard variable and tried to filter the values via the regex field. This works for static regex definition.
I would now like to use another variable inside the regex which provides the regex value.
So the regex field should look somehow like: /$theRealRegexVar/
I tried it with many different versions like /${theRealRegexVar}/
or /[[theRealRegexVar]]/
but it seems not to work.
Does it work somehow or is it simply impossible?
Update
The datasource is prometheus.
The regex would be a regex ;-) (for example "^.*$" - however the user would provide it in the other variable)
Solution 1:[1]
Don't know, if an answer is still relevant. But there are two options:
- Use
$theRealRegexVar
directly in the query that delivers the values of your dashboard variable. For sure this only applies if your variable is a query. - Apply a format option on
$theRealRegexVar
, see https://grafana.com/docs/grafana/latest/variables/advanced-variable-format-options/. A similar task worked for me with:raw
, so in your case put${theRealRegexVar:raw}
into the regex field.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | oidamo |