global:
  resolve_timeout: 5m
  # SMTP configuration for email alerts - use environment variables
  smtp_smarthost: '${SMTP_SMARTHOST:-smtp.example.com:587}'
  smtp_from: '${SMTP_FROM:-alertmanager@meldestelle.at}'
  smtp_auth_username: '${SMTP_AUTH_USERNAME:-alertmanager@meldestelle.at}'
  smtp_auth_password: '${SMTP_AUTH_PASSWORD}'
  smtp_require_tls: true

# The root route on which each incoming alert enters.
route:
  # The root route must not have any matchers as it is the entry point for all alerts
  # The default receiver is the one that handles alerts that don't match any of the specific routes
  receiver: 'email-notifications'

  # How long to wait before sending a notification again if it has already been sent successfully
  repeat_interval: 4h

  # How long to initially wait to send a notification for a group of alerts
  group_wait: 30s

  # How long to wait before sending a notification about new alerts that are added to a group
  group_interval: 5m

  # A default grouping of alerts
  group_by: ['alertname', 'cluster', 'service']

  # Child routes for specific alert categories
  routes:
  - receiver: 'slack-critical'
    matchers:
      - severity="critical"
    repeat_interval: 1h

  - receiver: 'slack-warnings'
    matchers:
      - severity="warning"
    repeat_interval: 12h

# Inhibition rules allow to mute a set of alerts given that another alert is firing
inhibit_rules:
  - source_matchers:
      - severity="critical"
    target_matchers:
      - severity="warning"
    # Apply inhibition if the alertname is the same
    equal: ['alertname', 'cluster', 'service']

# Receivers define notification integrations
receivers:
- name: 'email-notifications'
  email_configs:
  - to: 'admin@meldestelle.at'
    send_resolved: true

- name: 'slack-critical'
  slack_configs:
  - api_url: '${SLACK_WEBHOOK_URL_CRITICAL}'
    channel: '${SLACK_CHANNEL_CRITICAL:-#alerts-critical}'
    send_resolved: true
    title: '{{ .CommonAnnotations.summary }}'
    text: >-
      {{ range .Alerts }}
        *Alert:* {{ .Annotations.summary }}
        *Description:* {{ .Annotations.description }}
        *Severity:* {{ .Labels.severity }}
        *Instance:* {{ .Labels.instance }}
      {{ end }}

- name: 'slack-warnings'
  slack_configs:
  - api_url: '${SLACK_WEBHOOK_URL_WARNINGS}'
    channel: '${SLACK_CHANNEL_WARNINGS:-#alerts-warnings}'
    send_resolved: true
    title: '{{ .CommonAnnotations.summary }}'
    text: >-
      {{ range .Alerts }}
        *Alert:* {{ .Annotations.summary }}
        *Description:* {{ .Annotations.description }}
        *Severity:* {{ .Labels.severity }}
        *Instance:* {{ .Labels.instance }}
      {{ end }}
