Alertmanager alert routing¶
Alertmanager alert routing is the mechanism within Alertmanager that determines how incoming alerts are grouped, silenced, and which notification integrations receive the alert details.
Routing Configuration¶
Alertmanager routing logic is primarily defined in the configuration file (typically config.yml or alertmanager.yml) using a tree structure of routes^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].
The routing process begins at the root route configuration block^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].
Core Routing Concepts¶
Grouping¶
The group_by directive defines how alerts are aggregated before notifications are sent^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].
- Purpose: Alerts are grouped by specific labels (e.g.,
alertname,cluster). This ensures that multiple alerts related to the same issue are batched into a single notification^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. - Behavior: For example, grouping by
['alertname', 'cluster']aggregates all alerts sharing these two labels into one group.
Timing Parameters¶
Routing behavior is controlled by timing parameters that manage the frequency of notifications^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]:
group_wait: The time to wait before sending the first notification for a new group of alerts. This allows time for additional related alerts to arrive, preventing an initial flood of notifications^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].group_interval: The time to wait before sending a notification about new alerts that are added to an existing, already notified group^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].repeat_interval: The time to wait before resending a notification for an alert group that has already been sent^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].
Receivers¶
A receiver is a named configuration of one or more notification integrations (e.g., email, PagerDuty, Slack)^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].
The root route block includes a receiver parameter (often named default), which specifies the destination for alerts that do not match any specific child routes^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].
Routing Workflow¶
- Reception: Alertmanager receives alerts from Prometheus^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].
- De-duplication: It removes duplicate data^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].
- Grouping: It aggregates alerts based on the
group_bylabels^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. - Matching: It traverses the routing tree. If a child route matches (based on label matchers), it uses that route's receiver. If no child route matches, it falls back to the default receiver^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].
- Notification: It sends the notification via the configured channel (e.g., email)^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].