Search code examples
grafanagrafana-loki

Using regex to only return some of the Loki Label values


I am setting a Variable in Grafana.

I want to create a Query, that only returns a subset of the labels with value app the ones I want to return are those ending in dev

My Query so far, returns all of the labels with value app successfully. However, I have been unable to successfully filter the values so that only a-dev b-dev and c-dev are returned.

How do I successfully apply regex (or alternative) to this query so that I can see the desired values?

Any help on this would be greatly appreciated!

enter image description here


Solution

  • I eventually figured out what I needed to do. Originally I was trying to use | to run regex on the results from label_values.

    However, this format worked:

    label_values({app=~".*-dev$"}, app)
    

    and returned only a-dev b-dev c-dev as expected.