How to define a time interval each day when alert threshold is enable?

Hi, I want to relate only of a part of the day (between 2 hours e.g. 11AM and 11PM) about the value given. Also, I want to set a threshold (alert) only during this time in order to receive only relevant notification.

thanks,
Maurice

What datasource are you using?

Could you explain a little more what it is you want to accomplish? I’m a little confused by the time range description, as there are twelve hours between 11:00 and 23:00 and you’re talking about two hours.

Hi, I use prometheus as data source and I refer for example to a time interval (12 hours) i.e. between 11AM-11PM.
And only during this time, I want to define a threshold in alert. is it possible?

It’s kind of possible with Prometheus but not with Grafana. If you write sum(<metric>) * ((hour() > bool 11) * (hour() < bool 23)) you get a series where every hour which isn’t between 11:00-23:00 (UTC, you’ll have to adjust accordingly) is 0. I can’t seem to remember how to do that if you wanted to keep any labels though.

I have also been trying to find a best way for something like this. Not perfect yet but this is what I came up with. I also have Prometheus as db.:

Use hour() query for handling when the alerts are active and relative time range for displaying only parts of a day in the dashboard (now/d-2h to now/d+6h-1d):