Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cboudereau/cad6aab76f1f9a53c19788c383849587 to your computer and use it in GitHub Desktop.
Save cboudereau/cad6aab76f1f9a53c19788c383849587 to your computer and use it in GitHub Desktop.
google chat grafana notification template
{{ 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