# Alertmanager 配置 - Edu 平台
# 全局配置
global:
  resolve_timeout: 5m

# 告警模板（可扩展）
templates:
  - /etc/alertmanager/templates/*.tmpl

# 路由树
route:
  # 顶层默认接收器
  receiver: webhook-default
  # 按 alertname + service 分组
  group_by: ['alertname', 'service']
  # 首次告警等待时间（聚合相同组）
  group_wait: 30s
  # 同组新告警发送间隔
  group_interval: 5m
  # 重复告警发送间隔
  repeat_interval: 4h
  routes:
    # critical 告警走 webhook
    - matchers:
        - severity="critical"
      receiver: webhook-default
      continue: false
    # warning 告警走 webhook
    - matchers:
        - severity="warning"
      receiver: webhook-default
      continue: false

# 接收器列表
receivers:
  # 默认 Webhook 接收器（指向内部告警路由服务）
  - name: webhook-default
    webhook_configs:
      - url: http://alert-router:5001/alert
        send_resolved: true
        max_alerts: 0

  # 邮件接收器（注释示例，留作扩展）
  # 启用前需在 global.smtp_* 配置 SMTP 服务器
  # - name: mail-ops
  #   email_configs:
  #     - to: ops-team@example.com
  #       from: alertmanager@example.com
  #       smarthost: smtp.example.com:587
  #       auth_username: alertmanager@example.com
  #       auth_password: <SMTP_PASSWORD>
  #       require_tls: true
  #       headers:
  #         Subject: '[Edu Alert] {{ .GroupLabels.alertname }}'

  # 钉钉/企业微信接收器（注释示例，留作扩展）
  # - name: dingtalk-ops
  #   webhook_configs:
  #     - url: http://dingtalk-webhook:8060/dingtalk/ops/send
  #       send_resolved: true

# 抑制规则：critical 告警抑制同服务同名的 warning 告警
inhibit_rules:
  - source_matchers:
      - severity="critical"
    target_matchers:
      - severity="warning"
    # 相同 alertname + service 才抑制
    equal: ['alertname', 'service']
