Labels not rendering in alert summary and annotations - showing raw template syntax

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

  • What are you trying to achieve? Get the labels used in the queries and results as in the email notification

  • How are you trying to achieve it? create a test message with an custom annotation and create 2 test labels

  • What happened? The labels were printed in raw template syntax

  • What did you expect to happen? The value of the label or value itself is printed

Templating can be a bit tricky. First, it’s important to note that templating behaves differently depending on where it’s used.

The docs cover these separately as they use different variables and functions.

In your example, there are a couple of issues:

  • {{$labels}} only only contains query labels. Built-in labels like alertname are reserved and won’t appear there.
  • print query values like: {{$values.A.Value}}

Also, complex logic (loops, conditionals, formatting) is often defined in notification templates. When working with custom templates, the Preview feature in the UI is very helpful to validate what data is actually available and how it renders.

Hope this helps!

Hi,

Thanks for the answer, with the notification templates I found out that I have to reference the labels with Tablet: {{.Labels.tablet}}.