Alert Rule SQL Syntax Error

First, please let me know if this is a redundant issue. I tried searching but didn’t find anything that was exactly identical.

I am trying to set up a rule in Grafana to trigger an alert when the avg() aggregate function returns a value above a certain threshold. In this application, the value happens to be a temperature reading. The datasource is a MySQL database. I have attached images of my query builder page to display the query that is being examined for the rule. I have also attached an image of the rule configuration.

When I test the rule, I get the following error:

“tsdb.HandleRequest() response error &{Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘<time_column>) as time_sec, as value, as’ at line 2 A 0xc000617ae0 [] []}”

The raw sql output is the following:

"SELECT UNIX_TIMESTAMP(<time_column>) as time_sec, as value, as metric FROM

WHERE $__timeFilter(time_column) ORDER BY <time_column> ASC "

When I run this query manually on my MySQL database (filling in the variable names with the actual names defined in the database), the query is successful.

Any thoughts on why I might be getting this error? I’m not, or don’t believe I am, using template variables. I am using the timefilter macro, but I don’t see anywhere in the documentation that states you can’t use that macro (unless the macro itself uses template variables). Either way, removing the macro doesn’t resolve the issue.

RuleConfig

QueryBuilderView

I don’t know the cause or solution, but there is an open issue on Github: #19063.