Using 7 days average data as alert

Hi all, is it possible to use an average of 7 days data as a target for alert? Example, an alert will be triggered if the current value is 30% less than the average 7 days value.

Welcome @kaiyong

What is your datasource and what query language are you using?

Hi Grant2,

My datasource is influxDB and i’m using InfluxQL to qurey my time-series database.

I think a query like this

SELECT mean(value) FROM <measurement> WHERE time >= now() - 7d GROUP BY time(1d) fill(null)

in the alert section with an expression to compare against 30% of the result obtained by the query would work. Have you tried working through the alerting section of Grafana?

Hi @grant2 thanks, i think from your query it takes the 7 days data and average it. Sorry was not clear in my question. What i’m looking for is to find the average data of the same time, example, at 7pm, i would like to check for the past 7 days, the average value at 7pm, and if the current value at 7pm is 30% less than the average, it will trigger an alarm, and to check every 1 minute.

If you are willing to change to Flux, you can indeed filter / restrict by hour of the day using hourSelection in your query. Be aware that if you have already set up everything using InfluxQL, it may take some time to learn Flux, but it is definitely do-able.

1 Like

Thanks @grant2, i will try it.