I'm using Grafana v.8.3.4, with the unified alerting system enabled. I want to send a simple webhook-based alert. The alert fired correctly, but the body of the message use the default go template of Grafana.
The target
My goal is to correctly customised this message with the template mechanism introduced with the unified alerting system.
What i tried
I created a custom template in the "Contact points", and used the go directive for using a specific template in the message property of the alert rule, but the template is not correctly found, based on the grafana logs.
Here is the template i defined in the "contact points" menu :
{{ define "msgtemplate" }}
{{ len .Alerts.Firing }} firing. {{ len .Alerts.Resolved }} resolved.
Alerts Firing valueString : {{ .Alerts.Firing.ValueString }}.
Alerts Firing : {{ .Alerts.Firing }}.
Alerts Resolved: {{ .Alerts.Resolved }}.
Alerts : {{ .Alerts }}.
Labels : {{ .Alerts.Labels }}.
Values : {{ .Alerts.Values }}.
{{ end }}
Here is the way i refered to this template :
Summary and annotations:
AlertID = 1
Dashboard UID = OxXff5J7z
Panel ID: 2
message: {{template "msgtemplate" .}}
What i expect
I expect to get a customised message based on the values and alert properties.
What i get
I get an error in the grafana logs :
error in expanding template. Template \"msgtemplate\" not found
The name of the template seems to be correct. The field seems to be correctly interpreted in go; but the templates defined in the "contact points" menu seem to be unreachable. May you help me to get what i missed? Thank you very much for any help about my issue.