prometheus/oss/alertmanagerconfig.yaml (53 lines of code) (raw):
---
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
name: slack-config
labels:
alertmanagerConfig: slack
spec:
route:
receiver: 'slack-notifications'
groupBy: [alertname, job, app]
receivers:
- name: 'slack-notifications'
slackConfigs:
- apiURL:
name: alertmanager-slack-webhook
key: webhookURL
sendResolved: true
title: |
[{{ .Status | toUpper -}}
{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{- end -}}
] {{ .CommonLabels.alertname }}
text: |
{{- if eq .CommonLabels.severity "critical" -}}
*Severity:* `Critical` :red_circle:
{{- else if eq .CommonLabels.severity "warning" -}}
*Severity:* `Warning` :warning:
{{- else if eq .CommonLabels.severity "info" -}}
*Severity:* `Info` :information_source:
{{- else -}}
*Severity:* `Unknown` :interrobang: {{ .CommonLabels.severity }}
{{- end }}
{{- if (index .Alerts 0).Annotations.summary }}
{{- "\n" -}}
*Summary:* {{ (index .Alerts 0).Annotations.summary }}
{{- end }}
{{- if (index .Alerts 0).Labels.namespace }}
{{- "\n" -}}
*Namespace:* `{{ (index .Alerts 0).Labels.namespace }}`
{{- end }}
{{ range .Alerts }}
{{- if .Annotations.description }}
{{- "\n" -}}
{{ .Annotations.description }}
{{- "\n" -}}
{{- end }}
{{- if .Annotations.message }}
{{- "\n" -}}
{{ .Annotations.message }}
{{- "\n" -}}
{{- end }}
{{- end }}
color: '{{ if eq .Status "firing" -}}{{ if eq .CommonLabels.severity "warning" -}}warning{{- else if eq .CommonLabels.severity "critical" -}}danger{{- else -}}#439FE0{{- end -}}{{ else -}}good{{- end }}'