'Grafana : unable to customize webhook with templates

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 :

The template defined

Here is the way i refered to this template :

The way i refered to the template

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.



Solution 1:[1]

Hey don't think you are suppose to place the template in the annotations. It should be placed at the contact point. https://grafana.com/docs/grafana/latest/alerting/unified-alerting/message-templating/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Danial Ang