use grafana default message for ntfy alerts
This commit is contained in:
@@ -245,32 +245,10 @@ in {
|
|||||||
settings = {
|
settings = {
|
||||||
url = "$GRAFANA_NTFY_WEBHOOK_URL";
|
url = "$GRAFANA_NTFY_WEBHOOK_URL";
|
||||||
httpMethod = "POST";
|
httpMethod = "POST";
|
||||||
title = ''
|
# Let Grafana render its default title/message. The default message
|
||||||
{{ if eq .Status "resolved" }}RESOLVED{{ else }}FIRING{{ end }}: {{ index .CommonLabels "alertname" }}{{ with index .CommonLabels "target" }} {{ . }}{{ else }}{{ with index .CommonLabels "flow_id" }} {{ . }}{{ else }}{{ with index .CommonLabels "instance" }} {{ . }}{{ end }}{{ end }}{{ end }}
|
# includes all alert annotations via .Annotations.SortedPairs;
|
||||||
'';
|
# ntfy's grafana template then displays only title/message instead
|
||||||
message = ''
|
# of the full webhook JSON body.
|
||||||
{{ range .Alerts -}}
|
|
||||||
{{ $labels := .Labels -}}
|
|
||||||
{{ if eq .Status "resolved" }}✅ Resolved{{ else }}🚨 Firing{{ end }}: {{ index $labels "alertname" }}
|
|
||||||
{{ with index $labels "target" }}Target: {{ . }}
|
|
||||||
{{ end -}}
|
|
||||||
{{ with index $labels "flow_id" }}Flow: {{ with index $labels "namespace_id" }}{{ . }}/{{ end }}{{ . }}
|
|
||||||
{{ end -}}
|
|
||||||
{{ with index $labels "instance" }}Instance: {{ . }}
|
|
||||||
{{ end -}}
|
|
||||||
{{ with index $labels "severity" }}Severity: {{ . }}
|
|
||||||
{{ end -}}
|
|
||||||
{{ with .Annotations.SortedPairs }}Annotations:
|
|
||||||
{{ range . }}- {{ .Name }}: {{ .Value }}
|
|
||||||
{{ end -}}
|
|
||||||
{{ else }}{{ with $.CommonAnnotations.SortedPairs }}Annotations:
|
|
||||||
{{ range . }}- {{ .Name }}: {{ .Value }}
|
|
||||||
{{ end -}}
|
|
||||||
{{ end }}{{ end -}}
|
|
||||||
{{ with .GeneratorURL }}Source: {{ . }}
|
|
||||||
{{ end }}
|
|
||||||
{{ end -}}
|
|
||||||
'';
|
|
||||||
headers = {
|
headers = {
|
||||||
Template = "grafana";
|
Template = "grafana";
|
||||||
Markdown = "yes";
|
Markdown = "yes";
|
||||||
|
|||||||
Reference in New Issue
Block a user