Created
October 2, 2023 10:06
-
-
Save cboudereau/cad6aab76f1f9a53c19788c383849587 to your computer and use it in GitHub Desktop.
google chat grafana notification template
This file contains hidden or 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 "googlechat.subject" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ if gt (.Alerts.Resolved | len) 0 }}, RESOLVED:{{ .Alerts.Resolved | len }}{{ end }}{{ end }}] {{ .GroupLabels.SortedPairs.Values | join " " }} {{ if gt (len .CommonLabels) (len .GroupLabels) }}({{ with .CommonLabels.Remove .GroupLabels.Names }}{{ .Values | join " " }}{{ end }}){{ end }}{{ end }} | |
{{ define "googlechat.text_values_list" }}{{ if len .Values }}{{ $first := true }}{{ range $refID, $value := .Values -}} | |
{{ if $first }}{{ $first = false }}{{ else }}, {{ end }}{{ $refID }}={{ $value }}{{ end -}} | |
{{ else }}[no value]{{ end }}{{ end }} | |
{{ define "googlechat.text_alert_list" }}{{ range . }} | |
Value: {{ template "googlechat.text_values_list" . }} | |
{{ if gt (len .PanelURL) 0 }}<a href="{{ .PanelURL }}">Open Panel</a> | |
{{ end }}{{ end }}{{ end }} | |
{{ define "googlechat.title" }}{{ template "googlechat.subject" . }}{{ end }} | |
{{ define "googlechat.message" }}{{ if gt (len .Alerts.Firing) 0 }}**Firing** | |
{{ template "googlechat.text_alert_list" .Alerts.Firing }}{{ if gt (len .Alerts.Resolved) 0 }} | |
{{ end }}{{ end }}{{ if gt (len .Alerts.Resolved) 0 }}**Resolved** | |
{{ template "googlechat.text_alert_list" .Alerts.Resolved }}{{ end }} | |
{{ end }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment