Search code examples
prometheus-alertmanager

alertmanager v0.25.0: active_time_intervals configuration does not work--why?


Using alertmanager v0.25.0, and following documentation from alertmanager documenattion, I am unable to get active_time_intervals to work. My PagerDuty alerts still fire, even with active_time_intervals set.

I expected no alerts to fire except between 23:15 and 23:30, in the America/Denver time zone, with this configuration:

kube-prometheus-stack:
  alertmanager:
    alertmanagerSpec:
      replicas: 3
    config:
      global:
        resolve_timeout: 15m
      time_intervals:
        - name: business-hours
          time_intervals:
            - weekdays: ["monday:friday"]
              times:
                - start_time: "23:15"
                  end_time: "23:30"
              location: America/Denver
      route:
        group_by:
          - cluster
          - namespace
          - severity
          - alertname
        # A default receiver for all alerts
        receiver: [receiverName]
        # The child route trees
        routes:
          - receiver: [receiverName]
            active_time_intervals:
              - business-hours
            matchers:
              - alertname =~ "[alertNameHere]"

The alerts work with no active_time_intervals set. However, they also fire with active_time_intervals set, which I do not expect to happen. Does something need to be set somewhere else or is this configuration wrong?


Solution

  • Everything works as expected: since active_time_intervals is not satisfied route with this active_time_intervals is not used, but default route is used instead. And as you stated in comments receiver for default route is the same as for limited one.

    Generally, there is no reason to create separate route with the same receiver as default one if it is the only sub-route.

    For your case you need to make default receiver different from the sub-route's receiver.

    If you want to get mentioned alerts in another channel at times other then active_time_intervals use corresponding receiver as default.

    If you don't want to get this alerts at other times, you can use receiver: "null" as mentioned in this answer.