Use regex named group as label

I’ve created a regex filtering lines
{app="slimstampen-backend-production"} |~ api\/response\/getFirstCue\/(?P<lesson>\d*,)
and want to use the lesson variable/label

Any idea how to turn it into a label that can be used in a panel? I’m working in the grafana panel editor

1 Like

That’s one year old, however it’s a fairly reasonable ask and i had the same difficulty recently.
Here’s how I solved it:

  1. you need to use regexp to create labels out of named capture groups
  2. regexp alone however may not filter as you expect
  3. you may need a combination of |~ followed by | regexp

Putting it all together:

{app="slimstampen-backend-production"} 
  |~ "api\/response\/getFirstCue\/\d*," 
  | regexp "api\/response\/getFirstCue\/(?P<lesson>\d*,)"