Amjad Hussain Syed
Amjad Hussain Syed

Reputation: 1040

Grafana - use custom variable as regex in query

we have prometheus datasource and I’m stuck at trying to use custom variable with few values as comma separated values, I wanted to use it to replace as regex in the label_values(job=~$"{eks_cluster:regex}"), but i get the error templating variables could not be initialized. Following are the screenshots to show what I’m trying to achieve enter image description here

enter image description here

Upvotes: 1

Views: 19609

Answers (1)

Michał Politowski
Michał Politowski

Reputation: 4385

Your problem is not with the eks_cluster variable. This will just as much not work if the query is simply label_values(job=~".")

The label_values query, as described in Grafana documentation, takes either a label name or a label name and a metric name. It does not take a match to do whatever you wanted it to do. If you want to filter the values returned, use the Regex field just below Query.

Upvotes: 3

Related Questions