global:
  resolve_timeout: 5m

# 注意：
# 该文件为模板文件，生产环境必须先注入并渲染 `${ALERTMANAGER_*}` 变量，
# 再将渲染结果交给 Alertmanager 使用。

# 告警路由
route:
  group_by: ['alertname', 'service']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 12h
  receiver: 'default'

  # 子路由，根据严重级别分发
  routes:
    # Critical 告警
    - match:
        severity: critical
      receiver: 'critical-alerts'
      group_wait: 10s
      continue: true

    # Warning 告警
    - match:
        severity: warning
      receiver: 'warning-alerts'
      continue: true

# 告警接收者
receivers:
  # 默认接收者
  - name: 'default'
    email_configs:
      - to: 'ops-team@example.org'
        from: 'alertmanager@example.org'
        smarthost: 'smtp.example.org:587'
        auth_username: 'alertmanager@example.org'
        auth_password: 'synthetic-secret-for-render-drill'
        headers:
          Subject: '[{{ .Status | toUpper }}] {{ .GroupLabels.alertname }}'

  # Critical 告警接收者
  - name: 'critical-alerts'
    email_configs:
      - to: 'critical-oncall@example.org'
        from: 'alertmanager@example.org'
        smarthost: 'smtp.example.org:587'
        auth_username: 'alertmanager@example.org'
        auth_password: 'synthetic-secret-for-render-drill'
        headers:
          Subject: '[CRITICAL] {{ .GroupLabels.alertname }}'

  # Warning 告警接收者
  - name: 'warning-alerts'
    email_configs:
      - to: 'warning-oncall@example.org'
        from: 'alertmanager@example.org'
        smarthost: 'smtp.example.org:587'
        auth_username: 'alertmanager@example.org'
        auth_password: 'synthetic-secret-for-render-drill'
        headers:
          Subject: '[WARNING] {{ .GroupLabels.alertname }}'

# 告警抑制规则
inhibit_rules:
  # 如果有 critical 告警，抑制同一服务的 warning 告警
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    equal: ['service']

# 告警静默规则（按需配置）
# silences:
#   - matchers:
#       - name: alertname
#         value: LowOnlineUsers
#       - name: severity
#         value: info
#     startsAt: "2026-03-12T00:00:00+08:00"
#     endsAt: "2026-03-12T23:59:59+08:00"
#     comment: "维护期间静默低在线用户告警"

