Hi @grant2@melori.arellano I was trying to connect screenshots to my template, but it doesn’t work (Grafana v9.2.4). I use Microsoft Teams. This is my template:
{{ define “myalert” }}
{{ if gt (len .Annotations) 0 }}
Description:
{{ range .Annotations.SortedPairs }}
{{ .Name }}: {{ .Value }}
{{ end }}
{{ end }}
{{ if gt (len .PanelURL) 0 }}
Go to panel:
{{ .PanelURL }}
{{ end }}
{{ end }}
{{ define “mymessage” }}
{{ if gt (len .Alerts.Firing) 0 }}
{{ len .Alerts.Firing }} firing:
{{ range .Alerts.Firing }} {{ template “myalert” . }} {{ end }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
{{ len .Alerts.Resolved }} resolved:
{{ range .Alerts.Resolved }} {{ template “myalert” . }} {{ end }}
{{ end }}
{{ end }}
Mb I need to connect some function to my template.
By the way I have screenshots with default template, but it didn`t work with my custom template.
Hi! Screenshots are added to notifications (including Microsoft Teams) irrespective of the default or custom templates. Have you tried the troubleshooting instructions Use images in notifications | Grafana documentation?
Hi @georgerobinson
I saw your manual “Set up image rendering” and I noticed that image rendering is not supported at this time. You can check it in attachments.
Hi! I’m afraid I’m not the author of this page, but what it is saying is that you cannot screenshot entire dashboards, just individual panels within a dashboard. This isn’t an issue for alerting as if you add an alert to a panel its only the panel that will be screenshot.
Hi! I would like to share the 9.4 docs for templating notifications and would love to get some feedback from the community on what is good, what could be improved, and what is missing.
@georgerobinson That’s a nice try!
With v9 alerts messages are now very difficult to read, and it seems that the only way to customise messages is to use templates…
Unfortunately how-to instructions are quite difficult to find, even among Grafana docs…
Your doc Create message templates | Grafana documentation is a good start, but it would be very helpful to have a few examples for Slack notifications but for single alerts!!
Do you have by chance any examples to share?
Hi! Thanks for the feedback. I’m not sure I understand why you would want a notification template that only works for a single alert? What would happen if you had two alerts in the same notification?
@georgerobinson
In v8 alert notifications were forwarded one at a time (see attached screenshot).
Using the example as per your doc, alerts will be displayed one at a time as well?
I think maybe @robertojobet may be referring to the fact that when multiple alerts are put into a single Slack notification, it can be a bit difficult to read. For example, this is a Slack notification containing 2 alerts. It would be nicer to have them separated, but I believe that is not possible based on Grafana’s settings for the notification channel.
Hi @grant2
This is exactly what I’m referring to!
I presume that with the snippet that @georgerobinson is referring to in his docs, in case let’s say that 10 alerts are triggered all 10 alerts would be displayed in a single notification?!
That would be a nightmare…
If you would like each alert to be sent as a separate Slack message you can do this by changing the grouping in your notification policy. You will want to remove any labels in “Group by”. Grouping is unrelated to templates, and I would recommend writing templates that support any number of alerts per message in case you want to change the grouping later.