What regex language is used in dashboard->settings->variables?

TL;DR; Where do I go to learn more about regular expression syntax used in variables to filter dashboard panels?

I’m using version 9.2.1. I’m trying to setup variables to only match certain interfaces on cisco switches. I’m not having luck with the regexes I’ve been trying. What regex language does grafana use for the query options under variables?

I’m trying to return interface names like:
Gi1/0/1
Gi2/0/2
Gi1/1
Te1/0/1
Te2/0/2
Te1/1
Po1
Po30

And exclude interface names with certain strings like “Controlled” and “Vl”.

I’m not certain if I should be using the regex to filter the response I want, or if it should be part of the query. I’m using label_values(ifName) to pull all of the interface names. I came up with “^(Gi|Te|Po)\d+((/\d+)+(.\d+)?)?” at regex101 using golang, but that doesn’t work in grafana and I don’t even know if it should.

The regex pseudo code would be, "(Gi or Te or Po) followed by digits and maybe a (/ and more digits) maybe repeated, excluding anything with strings “Controlled” and “Vl”…if that makes sense.

You can try this on www.regex101.com with flavor Golang. Here is a direct link with filled data and regex:

Hi @lonelysysop,

Are those names what you want as a result or are they original/input names?

Can you share full names of interfaces and what result you would like to get?

Best regards,
ldrascic

That’s only true for the Prometheus data source, isn’t it?

Here I have a variable that is queried from an InfluxDB data source (from this dashboard):

And that seems to use a negative lookahead, which is somewhat famously not supported in Go.

1 Like

@andrekr is correct, i am not sure why the above is accepted as an answer. Grafana dashboard doesnt use golang regex. even example here doesnt use it: Add and manage variables | Grafana documentation