vin*_*ain 5 grafana grafana-templating grafana-alerts grafana-variable
我目前正在设置 grafana 警报。如何自定义消息模板,以便我的警报电子邮件显示服务器的 IP 地址、服务器的状态和节点/实例?
谢谢。
我曾经弄清楚过一次,然后最近我更新了我的 grafana 实例,这抹去了我的工作,我不得不再次弄清楚。第一次很艰难。
您可以使用以下语法在警报的摘要和描述部分中使用通过 prometheus 提供的标签:
{{$labels.instance}}
{{$labels.value}}
https://prometheus.io/docs/prometheus/latest/configuration/template_examples/
唯一的问题是,您必须在警报规则的最后一个条件中使用数学表达式,以便标签在警报的“摘要”部分中可用。
例如,在我们的个人警报中,我们将使用以下内容:
Machine {{$labels.instance}} is not reporting status via win-exporter.
The machine could be offline or the service could be stopped.
Run Code Online (Sandbox Code Playgroud)