clickhouse-datasource
clickhouse-datasource copied to clipboard
grafana's $__to and $__from are not supported in alerts
What happened:
I tried using grafana's $__from and $__to variables
in alert condition but got the following exception when testing alert condition:
request handler response error {error querying the database: code: 62, message: Syntax error: failed at position 861 ('$') (line 27, col 68): ${__from} / 1000))) and t < toStartOfMinute(toDateTime(toInt32(${__to} / 1000)))
-- where t + interval 1 hour > (toDateTime(toInt32(${__from} / 1000))) and . Expected one of: ALL, DISTINCT, token, Comma, ClosingRoundBracket, CAST operator, NOT, INTERVAL, CASE, DATE, TIMESTAMP, tuple, collection of literals, array, number, literal, NULL, NULL, Bool, TRUE, FALSE, string literal, asterisk, qualified asterisk, compound identifier, list of elements, identifier, COLUMNS matcher, COLUMNS, qualified COLUMNS matcher, substitution, MySQL-style global variable A <nil> [] [] 0xc003e27170}"
What you expected to happen:
alert evaluation should have been successful
How to reproduce it (as minimally and precisely as possible):
-
run grafana 10.3.3 with legacy alerting enabled
-
create a graph pannel with query that uses $__from an $__to in it:
select $__timeInterval(date_created) as t, count() from your_table
where date_created < toDateTime(${__to} / 1000) and date_created > toDateTime(${__from} / 1000)
group by t
order by t
-
make sure the graph works
-
go to legacy alerts page - try to press
Test rule
Screenshots
Environment:
- Grafana version: 10.3.3
- Plugin version: 4.2.0
- OS Grafana is installed on: linux
- User OS & Browser: chrome
- Others: