stacks/monitoring/alertmanager/templates/slack.tmpl

{{ define "slack.title" -}}
[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }}
{{- end }}

{{ define "slack.text" -}}
{{ range .Alerts -}}
*Severity:* `{{ .Labels.severity }}`
*Instance:* `{{ .Labels.instance }}`
*Summary:* {{ .Annotations.summary }}
{{ if .Annotations.description -}}
*Details:* {{ .Annotations.description }}
{{- end }}
*Started:* {{ .StartsAt.Format "2006-01-02 15:04:05 MST" }}
{{ if ne .Status "firing" -}}
*Resolved:* {{ .EndsAt.Format "2006-01-02 15:04:05 MST" }}
{{- end }}
{{ if .Annotations.runbook_url -}}
<{{ .Annotations.runbook_url }}|runbook>
{{- end }}
----
{{ end }}
{{- end }}

{{ define "slack.color" -}}
{{ if eq .Status "firing" -}}
{{ if eq .CommonLabels.severity "critical" -}}danger{{- else -}}warning{{- end }}
{{- else -}}good{{- end }}
{{- end }}

{{ define "slack.icon" -}}
{{ if eq .Status "firing" -}}
{{ if eq .CommonLabels.severity "critical" -}}:rotating_light:{{- else -}}:warning:{{- end }}
{{- else -}}:white_check_mark:{{- end }}
{{- end }}