0

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.

  • 1
    Have a look to this other post: https://stackoverflow.com/questions/57305247/how-to-inhibit-alerts-outside-business-hours-with-prometheus-alertmanager. Inhibit rule should behave the way you want – François Jan 02 '23 at 11:10

0 Answers0