Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grafana's $__to and $__from are not supported in alerts #887

Closed
vbichov opened this issue Jul 2, 2024 · 2 comments
Closed

grafana's $__to and $__from are not supported in alerts #887

vbichov opened this issue Jul 2, 2024 · 2 comments
Labels
datasource/ClickHouse priority/low question Further information is requested type/bug Something isn't working

Comments

@vbichov
Copy link

vbichov commented Jul 2, 2024

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):

  1. run grafana 10.3.3 with legacy alerting enabled

  2. 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
  1. make sure the graph works

  2. 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:
@SpencerTorres
Copy link
Collaborator

Have you tried different syntax for accessing these variables? It seems like it's not replacing the ${xxx} syntax. Either that or the variable isn't defined in alerts mode. Do these variables work with other datasources? Can you show the HTTP request payload? Usually the request itself will define the time range, so we can see whether it's included or not.

Usually I see these written as $__from and $__to. You could also try one of the macros which can replace the time for you.

@adamyeats adamyeats moved this from Incoming to Waiting in Partner Datasources Jul 23, 2024
@aangelisc aangelisc added question Further information is requested priority/low labels Jul 26, 2024
@bossinc
Copy link
Collaborator

bossinc commented Aug 19, 2024

@vbichov I am closing this issue. Please reopen if you still need help. 🙂

@bossinc bossinc closed this as completed Aug 19, 2024
@github-project-automation github-project-automation bot moved this from Waiting to Done in Partner Datasources Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasource/ClickHouse priority/low question Further information is requested type/bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

4 participants