# PromQL - Possible to query label by list of values?

**URL:** <https://community.grafana.com/t/promql-possible-to-query-label-by-list-of-values/35033>\
**Category:** Prometheus\
**Created:** [August 12, 2020, 4:12pm UTC](https://community.grafana.com/t/promql-possible-to-query-label-by-list-of-values/35033 "2020-08-12T16:12:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelblack](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/michaelblack/32/7069_2.png) [@michaelblack](https://community.grafana.com/u/michaelblack)\
**Post date:** [August 12, 2020, 4:12pm UTC](https://community.grafana.com/t/promql-possible-to-query-label-by-list-of-values/35033/1 "2020-08-12T16:12:14Z")

</div>

Is is possible in PromQL to query a label with a list of values? For example this is a how you’d do it in SQL:

```
SELECT *
FROM my_table
WHERE column_1 IN ('A', 'B', 'C')

```

Is there a similar syntax in PromQL? I would have imagined something like this:

`my_metric{Lable_1=["A", "B", "C"]}`

---

<div class="post-metadata">

**Author:** ![codlord](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@codlord](https://community.grafana.com/u/codlord)\
**Post date:** [August 12, 2020, 4:29pm UTC](https://community.grafana.com/t/promql-possible-to-query-label-by-list-of-values/35033/2 "2020-08-12T16:29:05Z")

</div>

You would use the regex match operator `=~` like this:

`my_metric{Lable_1=~"A"|"B"|"C"}`

If you use a Grafana list of values variable then it’s:

`my_metric{Lable_1=~"$MyVariable"}`

If you set a `Custom all value` of `.*` in your variable it may help performance if you have a long list of values.

More info:  
[https://prometheus.io/docs/prometheus/latest/querying/basics/](https://prometheus.io/docs/prometheus/latest/querying/basics/)

---

<div class="post-metadata">

**Author:** ![kurczynski](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@kurczynski](https://community.grafana.com/u/kurczynski)\
**Post date:** [October 29, 2021, 7:29pm UTC](https://community.grafana.com/t/promql-possible-to-query-label-by-list-of-values/35033/3 "2021-10-29T19:29:22Z")

</div>

This was super helpful for me, thanks! However, I did notice that

```auto
my_metric{Lable_1=~"A"|"B"|"C"}

```

should be:

```auto
my_metric{Lable_1=~"A|B|C"}

```

so the whole regex is quoted and not just the values. It explains it in the link you shared, but saves one more click for others 😀
