电子邮件警报模板通常位于/usr/share/grafana/public/emails/alert_notification.html
我们可以编辑该文件。
首先创建一个备份,
cd / usr / share / grafana / public / emails cp alert_notification.html alert_notification.html.bak
现在,我们可以编辑发送警报时使用的实际电子邮件模板HTML。
传递给电子邮件模板的可用属性是:
- Title
- State
- Name
- StateModel
- Message
- Error
- RuleUrl
- ImageLink
- EmbeddedImage
- AlertPageUrl
- EvalMatches
Grafana使用的实际GO脚本可以在GitHub上的https://github.com/grafana/grafana/blob/master/pkg/services/alerting/notifiers/email.go上查看。
可以在html模板中使用这样的值,
{ {.Title}} 要么 { {.Message}}
您可以检查其中的值,例如:
{
{if ne .EmbeddedImage "" }} {
{end}}
或者
{
{if eq .State