I'm setting up prometheus alerts for when there is 0 throughput for an API. But I want the alert to only be triggered only between 2pm UTC to 2am UTC (next day). What should be the syntax for this.
- name: API zero throughput alert
rules:
- alert: api-zero-throughput
annotations:
message: API throughput for the last 15m is zero
expr: sum by(path) (rate(http_request_duration_seconds_count{path="<api endpoint>",status=~"2.*|4.*"}[2m])) == 0
for: 30m
labels:
severity: warning
from my research I found out that hour() method is used for this purpose. But I can't seem to make it work in my case.