概述
Alertmanager 的 route 配置支持定义 树 状路由表,入口位置称为根节点, 每个字节点可以基于匹配条件定义出一个独立的路由分支。
所有的告警都将从路由根节点,而后进行子节点遍历。
若路由上的 continue 字段为 false, 则遇到第一个匹配的路由分支后即停止匹配, 否则将继续匹配后续的节点。
配置文件
route: # 路由组 group_by: ['alertname', 'app'] # group_wait: 30s group_interval: 40s repeat_interval: 1m smtp_auth_password: 'IZBJNCRVBAHLMAAB' # 认证秘钥 smtp_require_tls: false # 不启用 ssl templates: - './template/alertmanager-email.tmpl' route: # 路由组 group_by: ['alertname', 'app'] # group_wait: 30s group_interval: 40s repeat_interval: 1m receiver: email-receiver # 默认组 routes: - match_re: job: nodes continue: false receiver: email-receiver continue: false routes: - match_re: app: nginx receiver: web_team continue: false - match_re: app: mysql receiver: db_team continue: false receivers: # 收件人组 - name: 'email-receiver' email_configs: - to: 'aaa@sina.com' # 收件人地址 send_resolved: true - name: 'web_team' email_configs: - to: 'xx@qq.com' send_resolved: true # #是否通知已解决的警报。 - name: 'db_team' email_configs: - to: 'xx@aliyun.com' send_resolved: true # #是否通知已解决的警报。 inhibit_rules: - source_match: severity: 'critical' target_match_re: severity: '.*' equal: ['instance']