format grafana ntfy alerts

This commit is contained in:
2026-07-09 20:46:07 +02:00
parent 4c69d2476a
commit 4c09725317
@@ -245,6 +245,31 @@ in {
settings = { settings = {
url = "$GRAFANA_NTFY_WEBHOOK_URL"; url = "$GRAFANA_NTFY_WEBHOOK_URL";
httpMethod = "POST"; httpMethod = "POST";
title = ''
{{ 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 }}
'';
message = ''
{{ 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 index .Annotations "description" }}Details: {{ . }}
{{ end -}}
{{ with .GeneratorURL }}Source: {{ . }}
{{ end }}
{{ end -}}
'';
headers = {
Template = "grafana";
Markdown = "yes";
};
}; };
} }
]; ];