apiVersion: v1
kind: ConfigMap
metadata:
  name: alertmanager
  namespace: monitoring
data:
  config.yml: |-
    global:
      slack_api_url: 'https://hooks.slack.com/services/your_slack_api_token'
      smtp_smarthost: 'your_smtp_smarthost:587'
      smtp_from: 'your_smtp_from'
      smtp_auth_username: 'your_smtp_user'
      smtp_auth_password: 'your_smtp_pass'
    templates:
    - '/etc/alertmanager/template/*.tmpl'
    route:
      group_by: ['alertname', 'cluster', 'service']
      group_wait: 30s
      group_interval: 5m
      repeat_interval: 30m
      receiver: default-receiver
    inhibit_rules:
    - source_match:
        severity: 'critical'
      target_match:
        severity: 'warning'
      # Apply inhibition if the alertname is the same.
      equal: ['alertname', 'cluster', 'service']
    receivers:
    - name: 'default-receiver'
      slack_configs:
      - channel: '#your_slack_channel'
        title: '[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] Prometheus Event Notification'
        text: >-
            {{ range .Alerts }}
               *Alert:* {{ .Annotations.summary }} - `{{ .Labels.severity }}`
              *Description:* {{ .Annotations.description }}
              *Graph:* <{{ .GeneratorURL }}|:chart_with_upwards_trend:>
              *Details:*
              {{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
              {{ end }}
            {{ end }}
        send_resolved: true
      email_configs:
      - to: 'your_alert_email_address'
        send_resolved: true
