<p>After researching this, i've found an <a href="https://github.com/grafana/grafana/issues/25205" rel="nofollow noreferrer">open issue</a> on grafana's github. At the time of writing its still in the backlog.</p>

CC BY-SA 4.0
2020-11-30T05:59:41.790Z
2020-11-30T05:59:41.790Z
user2324712
<p>I want to create a query variable in grafana using Loki that returns all the possible label values of the label <strong>baz</strong> such that they only include label values that exist where the label <strong>foo</strong> equals <strong>&quot;bar&quot;</strong>.
Looking at the docs, I came up with the following query for the variable:</p>
<p>label_values(rate({foo=~&quot;bar&quot;}, baz)</p>
<p>However this returned all the possible baz label values and not only those that exist while foo=&quot;bar&quot;, basically the results are the same as:</p>
<p>label_values(baz)</p>
<p>What am I doing wrong? thank you.</p>

<prometheus><grafana>
How to filter label_values in Loki?
user2324712
# How to filter label_values in Loki?

(Asked by: username_0 on 2020-11-28)

I want to create a query variable in grafana using Loki that returns all the possible label values of the label **baz** such that they only include label values that exist where the label **foo** equals **"bar"**.
Looking at the docs, I came up with the following query for the variable:

label\_values(rate({foo=~"bar"}, baz)

However this returned all the possible baz label values and not only those that exist while foo="bar", basically the results are the same as:

label\_values(baz)

What am I doing wrong? thank you.

**Tags:** prometheus, grafana


---

## 1 answers

### Answer by username_0 on 2020-11-30. Score: 2 | Accepted answer

After researching this, i've found an [open issue](https://github.com/grafana/grafana/issues/25205) on grafana's github. At the time of writing its still in the backlog.


---

