Reputation: 15241
I'm trying to pass custom variables to prometheus via grafana variables.
The values I've got setup in grafana are as follows:
.+
(as a custom All
variable)eu.+
us.+
The variables are used in a query such as:
some_metric{availability_zone=~"$az", ...}
The All
variable works as expected, and the raw eu-.+
values etc when put directly into the query also work fine - but when the variable is assigned via a dropdown, no metrics are returned. eg:
some_metric{availability_zone=~"eu.+", ...}
..correctly matches all metrics with labels such as availability_zone="eu-west-1"
I've tried escaping and without in the custom values, but in for both of the custom values no metrics are returned.
What is wrong here?
Upvotes: 6
Views: 3665
Reputation: 2680
The way to do this seems to be:
some_metric{availability_zone=~"${az:pipe}", ...}
The two "gotchas" being that you need regex comparison "=~" and the ${variable:pipe} to get the regex to run.
Upvotes: 6
Reputation: 12981
To make PromQL use regular expressions when matching labels, you have to use =~
instead of =
.
Your query should look something like this:
some_metric{availability_zone=~"$az", ...}
Upvotes: 0