How to proper template messages on Grafana 8.3 New Alert Manager

  • What Grafana version and what operating system are you using?

Grafana 8.3.0 installled with Helm.

  • What are you trying to achieve?
    I am trying to get a properly formatted alert. For example, when I tested using the config.

  • How are you trying to achieve it?

I have tried the template and updated the message option in Contact Point according to this message-templating doc

  • What happened?

I received this

  • What did you expect to happen?

I hope it can be like

Firing: 
<Alert Name>
<summary>
<Description>
<labels>:
    <keya>: 1
    <keyb>: 2
    <keyc>: 3
  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

3 Likes

Can you show us a copy of the template you are using?

1 Like

I did not use any template now. I tried to use the one from doc. But it will not send any message when I use it. I did not setup any template, Just using the default format.

1 Like

as obiwan suggests, could you screenshot your alerting configuration? what are you putting in curly braces {{ }}?

1 Like

This one?

Ah, you are using DingDing. I have not messed with that contact point type yet. I am not sure that it supports templates. It does not mention templates.

You could try putting a template call in the “Message” field. Something like:
{{ template "<name.of.template.here>" }}.

For example, the default template can be called like this:
{{ template "default.message" }}.

You said that you have not setup any templates, so the only template defined in your system will be the default one.

2 Likes

@obiwan Thanks for your reply. But it seems not to work even with the default template.

Yeah, my guess is that DingDing does not support templates.

@obiwan I am getting same message format even if I am using slack without any additional massage formatting.

Yes, that is the default template. That is how it will always look unless you create/add a different template.

Can we have some better-looking templates with specific details about how to configure them? I have tried several times… And always failed to set up.

My main requests

  1. One notification for each issue
  2. Chart graph like 8.2 alerts.
  3. Short links instead of long links.
  4. Better text formatting for the value array.

Do you mean, a different template for each alert that triggers a notification? Or do you mean a customized notification for each different alert that you have created?

Having a chart in the notifications could be nice.

I agree, both of those requests would be nice.

1 Like

Just send a separate notification for each alert rather than have one notification with 5 issues in it. If I have 5 alerts fired up, Then I should get 5 messages. Then can share one template.

For 2,3,4 is there any article, tutorial to make it happen or we need to wait for new updates?

Related issue from github: After updating grafana to 8 telegram alerts is broken · Issue #43485 · grafana/grafana · GitHub

I think we will probably need to wait for updates.

Why can’t show the “Concact Point” menu in the Alerting secion? Any idea? (v8.3.3 installed)
image

I can’t found it:

Hi @sancho1234, your issue is that you’re still on Legacy Alerting.

By default, the “new” Unified Alerting should be switched on first: Opt-in to Grafana alerting | Grafana Labs

Oh gosh, why the heck this is not mentioned anywhere in the docs, how to assign a damn template to a damn alert/contact point… You separately create alerts, separately create templates and contact points, and it is not mentioned anywhere how to tie one to another. As alerts are connected to contact points via “Notification Policies”, I thought it should also be there, how wrong I was…

Grafana docs are simply in a terrible state…

4 Likes

if you make an issue detailing how the docs could be improved I’m sure the squads and writers would take a serious look at improving them :+1:

Did you ever find where you could select which alert is used? I cannot find it in the alert rules, nor in the contact points or the notification policies.

Also, how to format the Value array?