# Best workaround for alerting with template variables?

**URL:** <https://community.grafana.com/t/best-workaround-for-alerting-with-template-variables/1103>\
**Category:** Grafana\
**Created:** [May 25, 2017, 7:22pm UTC](https://community.grafana.com/t/best-workaround-for-alerting-with-template-variables/1103 "2017-05-25T19:22:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsha](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jsha/32/243_2.png) [@jsha](https://community.grafana.com/u/jsha)\
**Post date:** [May 25, 2017, 7:22pm UTC](https://community.grafana.com/t/best-workaround-for-alerting-with-template-variables/1103/1 "2017-05-25T19:22:57Z")

</div>

I use Grafana with a separate Prometheus datasource for each datacenter. I’ve found template variables very useful, to be able to write a single dashboard that can be used for each DC. Similarly, I’d like to write a set of alerts, and have them apply to each datacenter. I found [https://github.com/grafana/grafana/issues/6557](https://github.com/grafana/grafana/issues/6557), which indicates that alerting + template variables are a thorny problem, and may not be solved soon.

In the meantime, what’s the best workaround? I’m thinking of creating a single dashboard for alerts, set to a specific datacenter, then exporting it to JSON, committing it to our configuration repo, and turning it into a separate dashboard for each datacenter using sed. Is there a better way?

---

<div class="post-metadata">

**Author:** ![anonimito](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@anonimito](https://community.grafana.com/u/anonimito)\
**Post date:** [February 27, 2019, 2:22am UTC](https://community.grafana.com/t/best-workaround-for-alerting-with-template-variables/1103/2 "2019-02-27T02:22:36Z")

</div>

Did you ever get to a functional workaround for this?

---

<div class="post-metadata">

**Author:** ![jsha](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jsha/32/243_2.png) [@jsha](https://community.grafana.com/u/jsha)\
**Post date:** [February 27, 2019, 6:59pm UTC](https://community.grafana.com/t/best-workaround-for-alerting-with-template-variables/1103/3 "2019-02-27T18:59:29Z")

</div>

I wound up switching to alerting with Prometheus / Alertmanager.

---

<div class="post-metadata">

**Author:** ![ybello](https://avatars.discourse-cdn.com/v4/letter/y/958977/32.png) [@ybello](https://community.grafana.com/u/ybello)\
**Post date:** [April 10, 2019, 4:33pm UTC](https://community.grafana.com/t/best-workaround-for-alerting-with-template-variables/1103/4 "2019-04-10T16:33:54Z")

</div>

hey, any update on this open issue ? anyone ?

---

<div class="post-metadata">

**Author:** ![jemby](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jemby](https://community.grafana.com/u/jemby)\
**Post date:** [December 6, 2019, 7:23pm UTC](https://community.grafana.com/t/best-workaround-for-alerting-with-template-variables/1103/5 "2019-12-06T19:23:32Z")

</div>

I really like using Grafana but without alerts and email notification it make it a non starter. When is the problem going to be resolved with Template Variables?

---

<div class="post-metadata">

**Author:** ![kshull](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@kshull](https://community.grafana.com/u/kshull)\
**Post date:** [August 27, 2021, 4:39pm UTC](https://community.grafana.com/t/best-workaround-for-alerting-with-template-variables/1103/6 "2021-08-27T16:39:38Z")

</div>

+1  
Not being able to use template variable with alerts is a HUGE limitation with Grafana. Has this been addressed in 8.x?

---

<div class="post-metadata">

**Author:** ![kshull](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@kshull](https://community.grafana.com/u/kshull)\
**Post date:** [September 15, 2021, 4:33pm UTC](https://community.grafana.com/t/best-workaround-for-alerting-with-template-variables/1103/7 "2021-09-15T16:33:28Z")

</div>

I’ve added a feature request to template variables to be used in alerts:

> **[\[Feature Request\] Allow Template Variables To Be Used in Alert Queries ·...](https://github.com/grafana/grafana/discussions/39249)**
>
> Presently, you cannot use template variables in alert queries. Not having the ability to use template variables is a major gap in functionality since we have to hard code values in our queries to a...
