Use of embedded multi-value variables in regex

Hi, I’m new to Grafana so apologies if I’m missing something obvious.

I’m using a single (Prometheus/Thanos) data source - Grafana is configured to pull data from the Thanos query component. At the moment the Thanos query component has access to 2 Prometheus instances. Each of these Prometheus instances has a number of ‘external_labels’ - one of which is ‘cluster’ which I use as a variable in Grafana to focus the scope of data in my graphs.

I’m using Grafana v5.4.3 (6539180)

I’m running into trouble when I attempt to embed variables in the Regex field of Query Options of other variables - but only when the value of said embedded variables have multiple values. This is probably easier to illustrate:

If I select a single $cluster instance from my graph (e.g. and then view the $instance variable, the Preview of values is as I expect - i.e. the k8s API nodes are correctly filtered according to their $cluster:

Where I run into problems is if I select multiple clusters - e.g. +

Notice in this case the Preview of values is now erroneously $cluster values, not $instance values. I suspect that in this case, $cluster expands as a capture - e.g.


expands to


which results in two capture groups and appears to override my intended capture target for $instance.

If I’m correct, surely the expansion should instead use a non-capturing group?


Am I missing something or going about this the wrong way? Thanks if you’ve got this far - I’d appreciate any help solving this.



1 Like

I hit this as well, and filed a feature request.

I was in the same situation as you and I figured out how to do it:

The expression “${servers:pipe}” allows you to separate your values by a pipe that you then insert in a non-capturing group