Hi,
What I am trying to do
I am provisioning alert rules to read from a time series database (QuestDB) where I have different variables and a timestamp for each entry.
The query reads the last 300 points for each variable, and gets the maximum value. Sampling frequency is 1 second so that means I am getting the max value within the last 5 minutes.
The issue
If I do not define a relativeTimeRange for the Query, I get an error saying: Invalid relative time range: {From:0s To:0s)
What would I expect
No errors despite trying to build an alerting query without relativeTimeRange specified.
I think defining a relativeTimeRange within the Query is redundant (and it creates me a problem since the database is not synchronized with the local clock) since the query itself already has the time range considered (known number of points, 300, and sampling period, 1 second).
Isn’t there a way to avoid specifying the relativeTimeRange?
Thanks!
The relativeTimeRange is required field even if data source does not support it. Unfortunately, due to generic nature of the query definition, API does not know about the content of the query and whether data source support it, and therefore always requires it.
You can specify some value to pass the validation.
1 Like
Thanks for the answer @yuriy.tseretyan
Okey, got it, I will write some values to pass the validation then.
But that brings me to the next question, what is the actual role of this relativeTimeRange parameter? Does it influence anyhow the query?
It influences only data source queries. It tells the data sources that support a time range in queries (almost all), to query the data only in that interval of time.
For example, if you have alert rule that queries Prometheus datasource, the default setting now-10m
. When rule is evaluated, let’s say time X, the time range defined in the query transformed to the absolute time range from X-10m to X
and query is executed in Prometheus.
However, if alert rule queries SQL data source without special macros @_timeFilter
then the time range is ignored.