Browse Source

config.sample.yaml: alertmanager: update example (text|html)_template

Signed-off-by: Tom Herbers <mail@tomherbers.de>
pull/368/head
Tom Herbers 2 years ago
parent
commit
54a36221ba
No known key found for this signature in database GPG Key ID: 841A5B0DCEDA6192
  1. 29
      config.sample.yaml

29
config.sample.yaml

@ -163,6 +163,31 @@ services:
# Each room will get the notification with the alert rendered with the given template
rooms:
"!someroomid:domain.tld":
text_template: "{{range .Alerts -}} [{{ .Status }}] {{index .Labels \"alertname\" }}: {{index .Annotations \"description\"}} {{ end -}}"
html_template: "{{range .Alerts -}} {{ $severity := index .Labels \"severity\" }} {{ if eq .Status \"firing\" }} {{ if eq $severity \"critical\"}} <font color='red'><b>[FIRING - CRITICAL]</b></font> {{ else if eq $severity \"warning\"}} <font color='orange'><b>[FIRING - WARNING]</b></font> {{ else }} <b>[FIRING - {{ $severity }}]</b> {{ end }} {{ else }} <font color='green'><b>[RESOLVED]</b></font> {{ end }} {{ index .Labels \"alertname\"}} : {{ index .Annotations \"description\"}} <a href=\"{{ .GeneratorURL }}\">source</a><br/>{{end -}}"
text_template: >
{{range .Alerts -}}
{{- $severity := index .Labels "severity" -}}
{{- if eq .Status "firing" -}}
{{- if eq $severity "critical" -}} [CRITICAL]
{{- else if eq $severity "warning" -}} [WARNING]
{{- else if eq $severity "info" -}} [INFO]
{{- else -}} [{{ if $severity }}{{ $severity }}{{ else }}FIRING{{ end }}]
{{- end -}}
{{- else -}} [RESOLVED]
{{- end }} {{ index .Labels "alertname" -}}
{{- if index .Annotations "description" -}}: {{ index .Annotations "description" -}}{{- end }}
{{ end -}}
html_template: >
{{range .Alerts -}}
{{- $severity := index .Labels "severity" -}}
{{- if eq .Status "firing" -}}
{{- if eq $severity "critical" -}} <font data-mx-color="#ffffff" data-mx-bg-color="#ff0000"><b>[CRITICAL]</b></font>
{{- else if eq $severity "warning" -}} <font data-mx-color="#ffa500"><b>[WARNING]</b></font>
{{- else if eq $severity "info" -}} <font data-mx-color="#17a2b8"><b>[INFO]</b></font>
{{- else -}} <b>[{{ if $severity }}{{ $severity }}{{ else }}FIRING{{ end }}]</b>
{{- end -}}
{{- else -}} <font data-mx-color="#008000"><b>[RESOLVED]</b></font>
{{- end }} {{ index .Labels "alertname" -}}
{{- if index .Annotations "description" -}}: {{ index .Annotations "description" -}}{{- end -}}
{{- if .GeneratorURL }} (<a href="{{ .GeneratorURL }}">source</a>)<br/>{{- end }}
{{ end -}}
msg_type: "m.text" # Must be either `m.text` or `m.notice`
Loading…
Cancel
Save