Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grafana: Template variables are not supported in alert queries

Tags:

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

like image 909
Daniel Chepenko Avatar asked Jun 27 '18 02:06

Daniel Chepenko


People also ask

Why template variables are not supported in alert queries?

Solution. The "Template variables are not supported in alert queries" message comes from the fact that in the queries, the variable $hephy_app is in use. This variable usage is required, as at the point of Grafana creation (when the cluster is created) the application name(s) is/are unknown.

How do I use Grafana variables in Query?

To create a new variable, go to your Grafana dashboard settings, navigate to the Variable option in the side-menu, and then click the Add variable button. In this case, we use the Query type, where our variable will be defined as the result of an SQL query.

Does Grafana support alerting?

Grafana Alerting can give you system-wide visibility with a single multi-dimensional alert. One alert rule can alert on many items at once, creating one alert instance for each entity that needs your attention.


1 Answers

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

like image 70
ruhong Avatar answered Sep 19 '22 16:09

ruhong