How to use Grafana dashboard variable in another variables regex?
Asked Answered
R

2

7

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)

Rodrickrodrigez answered 6/2, 2019 at 10:32 Comment(1)
What is used datasource and regexp value?Razorback
R
1

Can I ask on the same subject if you can use a a variable in a regex for the next linked variable and so on.

So var1 is set var2 runs the query but to limit results in the regex you use var1. Something like this: /csm-e-${var1}.*/

Redmer answered 8/9, 2022 at 8:27 Comment(1)
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewMall
P
0

Don't know, if an answer is still relevant. But there are two options:

  1. 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.
  2. 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.
Proud answered 27/4, 2022 at 11:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.