---
apiVersion: v1
kind: ConfigMap
metadata:
  name: alertmanager
  namespace: monitoring
  labels:
    app: alertmanager
data:
  alertmanager.yml: |
    global: {}
    route:
      group_by: ['alertname', 'job']
      group_wait: 30s      # how long to wait to buffer alerts of the same group before sending a notification initially
      group_interval: 1h   # how long to wait before sending an alert that has been added to a group for which there has already been a notification
      repeat_interval: 30s # how long to wait before re-sending a given alert that has already been sent in a notification
      receiver: 'slack_homelab' # default/fallback request handler
      # Send severity=warning alerts to slack
      routes:
      - receiver: slack_homelab
        match:
          severity: warning      
    # See https://lisenet.slack.com/apps/A0F7XDUAZ-incoming-webhooks
    receivers:
    - name: 'slack_homelab'
      slack_configs:
      - api_url: SLACK_WEBHOOK_URL
        channel: '#homelab'
        send_resolved: true
        title: "[{{ .Status | toUpper }}] {{ range .Alerts }}{{ .Annotations.summary }}\n{{ end }}"
        text: |-
          {{ range .Alerts }}*Description:* {{ .Annotations.description }}
          *Context:* {{ .Labels.context }}
          *Cluster:* {{ .Labels.cluster }}
          *Severity:* {{ .Labels.severity }}
          {{ end }}
