Created
September 15, 2021 13:44
-
-
Save mkopinsky/9b982ba432b780c525ff3e65a78a5dac to your computer and use it in GitHub Desktop.
Slack template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ define "alert" }} | |
{{ if eq .Status "firing" }}:fire: {{ else }}:white_check_mark: {{ end -}} | |
*{{ .Labels.alertname }}* {{ if .Annotations.summary }} ({{ .Annotations.summary }}){{ end }} | |
{{- if eq .Status "firing" }} | |
> ```{{ .ValueString}}``` | |
{{- end -}} | |
{{- if gt (len .Labels) 1 }} | |
> {{ range .Labels.SortedPairs }} *{{ .Name }}:* {{ .Value }} {{ end }} | |
{{ end }} | |
{{- if gt (len .Annotations) 0 }} | |
> {{ range .Annotations.SortedPairs }} *{{ .Name }}:* {{ .Value }} {{ end }} | |
{{ end -}} | |
> {{ if gt (len .GeneratorURL ) 0 }}<{{ .GeneratorURL }}|:pencil2: Alert>{{ end }} {{ if gt (len .SilenceURL ) 0 }}<{{ .SilenceURL }}|:no_bell: Silence>{{ end }} {{ if gt (len .DashboardURL ) 0 }}<{{ .DashboardURL }}|:earth_americas: Dashboard>{{ end }} {{ if gt (len .PanelURL ) 0 }}<{{ .PanelURL }}|:bar_chart: Panel>{{ end }} | |
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ define "message" }} | |
{{- if gt (len .Alerts.Firing) 0 -}} | |
{{ len .Alerts.Firing }} firing: | |
{{- range .Alerts.Firing -}} {{ template "alert" .}} {{- end -}} | |
{{ end }} | |
{{- if gt (len .Alerts.Resolved) 0 -}} | |
{{ len .Alerts.Resolved }} resolved: | |
{{- range .Alerts.Resolved -}} {{ template "alert" .}} {{- end -}} | |
{{ end }} | |
{{ end }} |
Author
mkopinsky
commented
Sep 15, 2021
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment