Grafana: Template variables are not supported in alert queries

Daniel Chepenko picture Daniel Chepenko · Jun 27, 2018 · Viewed 19.3k times · Source

Hi I want to create a simple alert in grafana to check whether there is no data for the last 5 minutes.

But I get an error

Template variables are not supported in alert queries

Well, according to this issue templates are not supporting in grafana yet. I have two questions:

  1. What is templating?

  2. How can I avoid this error?

enter image description here

Answer

ruhong picture ruhong · Nov 7, 2019

Under the Metrics tab, add new metric that will be hidden in the chart and is used for alerting only. Duplicate the query and remove all template variables (i.e. $somevar) from it. Replace the template variable with a hard-coded value you want to create alert for. Hide the metric by clicking on the “eye” icon.

Source: https://community.grafana.com/t/template-variables-are-not-supported-in-alert-queries-while-setting-up-alert/2514/8