Regex involving underscore in Grafana dashboard's drop down menu

Grafana v10.4.2 (22809dea50) on linux

I’m trying to create regex to select only few items from drop down list in my grafana dashboard

Regex which is working in regex101 is not not working here.

Sample Data in the menu drop down coming from a variable:
Intl_New_City_Highway,
Intl_New_City_Track_Pathway,
USA_NY_Newyork_City_Buildings,
USA_NJ_Newark_City_Track,
USA_CA_New_City_Napa_Track,
Space_New_City_Track_Field,
USA_LA_NewOrleans_City_Track,
USA_NewMexico_Albuquerque_City_Building

Below regex string in regex101 gives me
(New_City_Track)

Intl_New_City_Track_Pathway
Space_New_City_Track_Field

But the similar regex string in Grafana gives me

Intl_New_City_Track_Pathway
Space_New_City_Track_Field
USA_CA_New_City_Napa_Track
USA_LA_NewOrleans_City_Track
USA_NJ_Newark_City_Track

which flavour are you selecting in regex101?

grafana uses golang…

image

what regex value are you using? are you doing it in the variable definition itself? how are you doing it in the variable definition?

Yes. I’m using golang Flavor in regex 101

This works for me in regex101, but not in grafana.
(New_City_Track)

The static values are defined in variables for this use case.

I’m using the regex in the drop down menu in the dashboard.

I’m expecting only two values (below) to remain in the drop down out of seven values, when I put this regex in the drop down search ( (New_City_Track) ) :

Intl_New_City_Track_Pathway
Space_New_City_Track_Field

are you doing it in the variable definition itself? how are you doing it in the variable definition? share screen capture of definition

Variable definition screenshot :


Drop down result screenshot
Screenshot 2024-05-10 at 00.46.50

1 Like

Is there documentation that shows you can use regex in the drop down itself?

It works fine in Grafana v9.5.x

my question was is it documented

Thats the mystery !

By the way, what worked in Grafana v9.5.x is not working in Grafana v10.5.x

As suggested by this post, the pattern /^(New_City_Track)$/ doesn’t work in Grafana v10.4.x
While i’m expecting only 2 results, as provided by regex101 as well,

Intl_New_City_Track_Pathway
Space_New_City_Track_Field

however i’m getting 5 results.

Intl_New_City_Track_Pathway
Space_New_City_Track_Field
USA_CA_New_City_Napa_Track
USA_LA_NewOrleans_City_Track
USA_NJ_Newark_City_Track

I do see that my expected result are the top 2 from the list of 5, i just need to find out how to be more explicit in the pattern