# Filter label\_value function with query on value

**URL:** <https://community.grafana.com/t/filter-label-value-function-with-query-on-value/54110>\
**Category:** Grafana\
**Created:** [October 3, 2021, 2:55pm UTC](https://community.grafana.com/t/filter-label-value-function-with-query-on-value/54110 "2021-10-03T14:55:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![f1outsourcing](https://avatars.discourse-cdn.com/v4/letter/f/a183cd/32.png) [@f1outsourcing](https://community.grafana.com/u/f1outsourcing)\
**Post date:** [October 3, 2021, 2:55pm UTC](https://community.grafana.com/t/filter-label-value-function-with-query-on-value/54110/1 "2021-10-03T14:55:40Z")

</div>

This question has already been asked, but instead a work around has been given.

This generates output  
`label_values(libvirt_domain_state_code{instance=~"$instance"} , domain)`

This is a valid prometheus query that generates output  
`libvirt_domain_state_code{instance=~"xxx"} == 1`

However this does not work  
`label_values(libvirt_domain_state_code{instance=~"$instance"}==1 , domain)`

> [@How to filter result of label\_value?](https://community.grafana.com/t/how-to-filter-result-of-label-value/12069):
>
> Hi, we are running a platform of jobs, there are one or more tasks in single job, so we are exporting metrics like: task\_mem\_usage{"job"="a", "task\_name"="1"} 2 task\_mem\_usage{"job"="a", "task\_name"="2"} 3 task\_mem\_usage{"job"="b", "task\_name"="1"} 2 we want users can see both job-level metrics and task-level metrics. So we defined two variables: job and task, the query for job is easy: label\_values(task\_mem\_usage, job). But if task is defined as label\_values(task\_mem\_usage, task\_name), it wo…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/grafana/original/2X/e/ef5308cc58c9e5a13187b5012eb99f406928462f.png) [@system](https://community.grafana.com/u/system)\
**Post date:** [October 3, 2022, 2:56pm UTC](https://community.grafana.com/t/filter-label-value-function-with-query-on-value/54110/2 "2022-10-03T14:56:16Z")

</div>

Closed on October 3, 2022, 2:56pm UTC

This topic was automatically closed after 365 days. New replies are no longer allowed.
