Skip to content

Change Email Alert Template

This document was written for Grafana 7.

For versions of Grafana, before version 9, the email alert template is usually located at /usr/share/grafana/public/emails/alert_notification.html.

But since version 9 look for a file named ng_alert_notification.html and there are probably many other breaking differences than mentioned in this document. So good luck, you will need to do your own research.

If you are using Grafana 7 or 8, then we can edit this file.

First create a backup,

cd /usr/share/grafana/public/emails
cp alert_notification.html alert_notification.html.bak

Now we can edit the actual the Email template HTML used when sending the alert.

The available properties that are passed to the email template are,

  • Title
  • State
  • Name
  • StateModel
  • Message
  • Error
  • RuleUrl
  • ImageLink
  • EmbeddedImage
  • AlertPageUrl
  • EvalMatches

The actual GO script that Grafana uses can be viewed here on GitHub at

Values can be used inside the HTML template like this,

{{.Title}} or {{.Message}}

You can check there values, e.g.,

{{if ne .EmbeddedImage "" }}
    <!--If .EmbeddedImage is not an empty string, then add it like below-->
    <img src="cid:{{.EmbeddedImage}}" />


{{if eq .State "ok" }}
    <!--Do things if the state = ok-->

You can iterate if it is an array, e.g.,

{{range .EvalMatches}}
    &nbsp;&nbsp;.Metric = {{.Metric}}<br/>

And you can get its attributes if it is an object, e.g.,


See the official file at /usr/share/grafana/public/emails/alert_notification.html for more examples. Search for the {{ string in the file to see several ways of how the variables can be used.

Simplified Email Template

This is a very simplified email template demonstrating the use of all the above variables. Overwrite the file alert_notification.html with this code below. Ensure you have backed up the original alert_notification.html file though, you may want it later.

This is a much more simplified email template written specifically to help understand the available properties better. You can experiment with this until you create your own custom email template suitable for your needs.

<!DOCTYPE html>
<html xmlns="">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width" />

        <p>.Title = {{.Title}}</p>

        <p>.State = {{.State}}</p>

        <p>.Name = {{.Name}}</p>

            .StateModel = {{.StateModel}}<br />
            .StateModel.Color = {{.StateModel.Color}}<br />
            .StateModel.Text = {{.StateModel.Text}}<br />

        <p>.Message = {{.Message}}</p>

        <p>.Error = {{.Error}}</p>

        <p>.RuleUrl = {{.RuleUrl}}</p>

        <p>.ImageLink = {{.ImageLink}}</p>

            .EmbeddedImage = {{.EmbeddedImage}}<br />
            {{if ne .EmbeddedImage "" }}
            <img src="cid:{{.EmbeddedImage}}" />

        <p>.AlertPageUrl = {{.AlertPageUrl}}</p>

            .EvalMatches = {{.EvalMatches}}<br />
            {{range .EvalMatches}} &nbsp;&nbsp;.Metric = {{.Metric}}<br />
            &nbsp;&nbsp;.Value = {{.Value}}<br />
            &nbsp;&nbsp;.Tags = {{.Tags}}<br />

When editing the template, changes won't be applied until you restart the Grafana Server service.

Also, the different properties listed above are available dependent on which state the alert was in, so sometimes you won't see any values.

Restart the service after any changes to the email template HTML file

sudo service grafana-server restart

If there are any errors in your script, some of them may be detected when the Grafana service restarts, and will be written to the log. So I advise you open a separate SSH session and tail the log file in case any errors are detected when you restart the service.

tail -f /var/log/grafana/grafana.log

Tailing the Grafana Server log file is also useful to see when each of the alerting states changes, and maybe there will be errors displayed in the console as well.