# Alertmanager Configuration for Orion Platform
# Docs: https://prometheus.io/docs/alerting/latest/configuration/

global:
  resolve_timeout: 5m

  # ─── SMTP Configuration (SendGrid) ──────────────────────────────────
  # Sign up at sendgrid.com, create an API key, authenticate wizard.lu domain
  # Username is literally the string "apikey", password is your SG.xxx API key
  smtp_smarthost: 'smtp.sendgrid.net:587'       # SendGrid SMTP relay
  smtp_from: 'alerts@wizard.lu'                 # Must match authenticated domain
  smtp_auth_username: 'apikey'                  # Always "apikey" for SendGrid
  smtp_auth_password: ''                        # TODO: Paste your SG.xxx API key here
  smtp_require_tls: true

route:
  # Group alerts by name and severity
  group_by: ['alertname', 'severity']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 4h
  receiver: 'email-warnings'

  routes:
    # Critical alerts: repeat every 1 hour
    - match:
        severity: critical
      receiver: 'email-critical'
      repeat_interval: 1h

    # Warning alerts: repeat every 4 hours
    - match:
        severity: warning
      receiver: 'email-warnings'
      repeat_interval: 4h

receivers:
  - name: 'email-critical'
    email_configs:
      - to: 'admin@wizard.lu'                  # TODO: Replace with your alert recipient
        send_resolved: true
        headers:
          Subject: '[CRITICAL] Orion: {{ .GroupLabels.alertname }}'

  - name: 'email-warnings'
    email_configs:
      - to: 'admin@wizard.lu'                  # TODO: Replace with your alert recipient
        send_resolved: true
        headers:
          Subject: '[WARNING] Orion: {{ .GroupLabels.alertname }}'

# Inhibition rules — suppress warnings when critical is already firing
inhibit_rules:
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    equal: ['alertname', 'instance']
