Variable with a regular expression

What Grafana version and what operating system are you using?

  • Oracle Linux Server 8.8
  • Grafana 10.1.1

I want to query multiple service statuses from a Zabbix data source.

To make it a bit easier, I’ve set up a constant variable with the following regex value:
all_services = /^Service1$|^Service2$|^Service3$|^ServiceN$/

services_var

Actual service names are very different and have no clear pattern.


I would like to use this variable in some queries.
query_with_var

When I use the variable like this, the query returns no data.
When I use the regex directly, it returns all service states.

How can I use variables with regex, or maybe use a string array?

Not sure if this is still relevant, but I was able to solve a similar issue on my end by specifying additional format options.

Variable syntax | Grafana documentation

For your example use the following when referencing your variable:

${all_services:raw}
1 Like

That is what I needed!

It is now working. Thank you.