Skip to content

Commit 0e04195

Browse files
committed
chore(alertmanager): improve slack templates
1 parent 13f0315 commit 0e04195

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

locals.tf

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,30 @@ locals {
9494

9595
alertmanager_template_files = length(local.alertmanager.slack_routes) > 0 ? {
9696
"slack.tmpl" = <<-EOT
97-
{{ define "slack.title" -}}
98-
[{{ .Status | toUpper }}
99-
{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{- end -}}
100-
] {{ .CommonLabels.alertname }}
101-
{{ end }}
102-
{{ define "slack.text" -}}
103-
{{ range .Alerts }}
104-
*Alert:* {{ .Annotations.summary }} - `{{ .Labels.severity }}`
105-
{{- if .Annotations.description }}
106-
*Severity:* `{{ .Labels.severity }}`
107-
*Description:* {{ .Annotations.description }}
108-
{{- end }}
109-
*Graph:* <{{ .GeneratorURL }}|:chart_with_upwards_trend:>
110-
*Labels:*
111-
{{ range .Labels.SortedPairs }} - *{{ .Name }}:* `{{ .Value }}`
112-
{{ end }}
113-
{{- if .Annotations.runbook_url }}
114-
*Runbook URL:* <{{ .Annotations.runbook_url }}|Click here>
115-
{{- end }}
97+
{{ define "slack.title" -}}
98+
[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }}
99+
{{ end }}
100+
101+
{{ define "slack.text" -}}
102+
{{ with index .Alerts 0 -}}
103+
:chart_with_upwards_trend: *<{{ .GeneratorURL }}|Source Graph>*
116104
{{ end }}
105+
{{- range .Alerts -}}
106+
*Severity:* `{{ .Labels.severity }}`
107+
{{- if .Annotations.summary }}
108+
*Alert:* {{ .Annotations.summary }}
109+
{{- end }}
110+
{{- if .Annotations.description }}
111+
*Description:* {{ .Annotations.description }}
112+
{{- end }}
113+
{{- if .Annotations.runbook_url }}
114+
*Runbook URL:* <{{ .Annotations.runbook_url }}|Click here>
115+
{{- end }}
116+
*Labels:*
117+
{{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
118+
{{ end }}
117119
{{ end }}
120+
{{ end }}
118121
EOT
119122
} : {}
120123

0 commit comments

Comments
 (0)