Grafana alert condition does not work when query has WHERE $timeFilter


I need to create a query using raw data because it includes a calculation between fields.
I am trying to create an ALERT based on that but when I include AND $timeFilter, the Alert query fails.
If I remove it the alarm works but my query results do not look correct…The query I am using in the alarm condition is C.

Is this a bug? Is there a workaround?

$timeFilter is essential, should be in all your queries.

We have no other reports on issues with this time range macro, What is the error you get?

I am posting with the $timeFilter and without. Note that I have created a template for apn and host but in the query I created the alarm I have removed the template and use actual value.


There were two different issues.

  1. The problem with using $timeFilter was that I had the alarm query set to 5m,now which is the default and i didn’t have two samples to calculate the derivative. Once I set the period to 10m, now it was ok.
  2. It looks like when I duplicate a Query from metrics that contains a template, and then edit it to remove the template, I cannot use this query. Grafana displays this Template variables are not supported even if my query doesnt have any. When I created a new Query even though it was the same as before, I don’t get this warning and alert works. I think this is a Bug

I am using 4.1.2