# Prometheus Variables Not Working

**URL:** <https://community.grafana.com/t/prometheus-variables-not-working/107979>\
**Category:** Dashboards\
**Tags:** dashboard-variables, promql\
**Created:** [November 16, 2023, 5:58pm UTC](https://community.grafana.com/t/prometheus-variables-not-working/107979 "2023-11-16T17:58:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasonmallory](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jasonmallory/32/36686_2.png) [@jasonmallory](https://community.grafana.com/u/jasonmallory)\
**Post date:** [November 16, 2023, 5:58pm UTC](https://community.grafana.com/t/prometheus-variables-not-working/107979/1 "2023-11-16T17:58:17Z")

</div>

I am currently modifying a dashboard to work with my Prometheus data source. I put in the dashboard variables and the query returns what I am looking for:

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/c/7/c7850bbef2a5f981bfc76e5fd50ed0664fe25e10.png)

However, when I try the variable in my visual I get no data:

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/e/5/e5d0aed62cb6e224761c74e4269c9af964baed9d.png)

![image](https://us1.discourse-cdn.com/grafana/original/3X/c/8/c84690feccb6687defdd61e5d56aa4e57c7f1b16.png)

If I enter the metric statically I get data:

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/b/8/b8e3351e5d51de2b8a8b6f13feec875daaa8d89a.png)

![image](https://us1.discourse-cdn.com/grafana/original/3X/1/1/1102f13570fe732c087948eab45ccab66c1f5eb7.png)

Any ideas?

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [November 16, 2023, 7:01pm UTC](https://community.grafana.com/t/prometheus-variables-not-working/107979/2 "2023-11-16T19:01:36Z")

</div>

What does it look like when you click on Query Inspector?

It might be you need to use interpolation like `${host:csv}`?

Check following out

> **[Variable syntax | Grafana documentation](https://grafana.com/docs/grafana/latest/dashboards/variables/variable-syntax/)**
>
> Variable syntax Panel titles and metric queries can refer to variables using two different syntaxes:
> $varname This syntax is easy to read, but it does not allow you to use a variable in the middle of a word. Example:...

---

<div class="post-metadata">

**Author:** ![jasonmallory](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jasonmallory/32/36686_2.png) [@jasonmallory](https://community.grafana.com/u/jasonmallory)\
**Post date:** [November 16, 2023, 7:17pm UTC](https://community.grafana.com/t/prometheus-variables-not-working/107979/3 "2023-11-16T19:17:36Z")

</div>

The $hostname variable works just fine. I’ve tested it in Explore and the query inspector. The inspector comes back with no data on thee $cpu variable, yet it recognizes the variable:

![image](https://us1.discourse-cdn.com/grafana/original/3X/6/9/6943eebce3b4370b6d0d7e3c6d932aa839f65259.png)

---

<div class="post-metadata">

**Author:** ![jasonmallory](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jasonmallory/32/36686_2.png) [@jasonmallory](https://community.grafana.com/u/jasonmallory)\
**Post date:** [November 16, 2023, 7:18pm UTC](https://community.grafana.com/t/prometheus-variables-not-working/107979/4 "2023-11-16T19:18:55Z")

</div>

In the dashboard variable:

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/4/6/46bd7d3e0db3851fa0f5e63ca0b0c01b0400f70d.png)

---

<div class="post-metadata">

**Author:** ![jasonmallory](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jasonmallory/32/36686_2.png) [@jasonmallory](https://community.grafana.com/u/jasonmallory)\
**Post date:** [November 16, 2023, 7:23pm UTC](https://community.grafana.com/t/prometheus-variables-not-working/107979/5 "2023-11-16T19:23:25Z")

</div>

I figured it out. I needed to write me regex to include cpu-total

> /cpu[0-9]|cpu-total/

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/a/5/a5000d48564c263f36b8a666b80d0f4035fec7a8.png)
