Trigger Grafana alert on specific hours

Viewed 170

Im using Grafana 8.2.3 and its unified alerting feature, the datasource is Prometheus. We would like to create an alert which will be triggered only during the night from 01:00 to 05:00. I have the following query, which tries to alert on high cpu usage for all the hosts, but it throws no data

(100-(avg by (instance) (irate(windows_cpu_time_total{job=~"windows_scrape",mode="idle"}[2m])) * 100)) * ((hour() > 8) * (hour() < 10))

the following query works, but its only for one host:

100 - avg(irate(windows_cpu_time_total{instance=~"instance.name.com:9182",mode="idle"}[5m]))*100 * ((hour() > 8) * (hour() < 14))

what im doing wrong?

0 Answers
Related