# =============================================================================
# Alertmanager 配置 - 告警通知管理
# =============================================================================

global:
  resolve_timeout: 5m

route:
  group_by: ['alertname', 'severity']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 1h
  receiver: 'telegram-webhook'
  routes:
    # 高優先級告警 - CPU/RAM 超過 50%
    - match:
        severity: warning
      receiver: 'telegram-webhook'
      group_wait: 10s
      repeat_interval: 30m

    # 嚴重告警 - CPU/RAM 超過 80%
    - match:
        severity: critical
      receiver: 'telegram-webhook'
      group_wait: 5s
      repeat_interval: 15m

receivers:
  - name: 'telegram-webhook'
    webhook_configs:
      - url: 'http://momo-pro-system:5000/api/alert/webhook'
        send_resolved: true
        http_config:
          basic_auth:
            username: 'alertmanager'
            password: 'wooo_alert_2026'

inhibit_rules:
  # 如果已有 critical 告警，抑制 warning 告警
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    equal: ['alertname', 'instance']
