5

I am currently setting up grafana alerts. How do I customize my message template so my alert email shows The ip address of the server, the state of the server and the node/instance?

Thank you.

  • I made an assumption when I provided my answer that you were using grafana with prometheus as the source. If you were, add prometheus as a tag and accept my answer if it helps. Otherwise, it would be helpful to list what you are using to source your datas and what alerts are you creating on that – Kyle Burkett Nov 10 '22 at 16:10

1 Answers1

0

I figured it out once, then recently I updated my grafana instance that wiped my work and I had to figure it out again. It was tough the first time.

You can use the labels that are made available through prometheus in your summary and description sections in your alerts by using the syntax:

{{$labels.instance}} {{$labels.value}}

https://prometheus.io/docs/prometheus/latest/configuration/template_examples/

The only catch is that you have to use Math expression in the last condition in your alert rule for the labels to be available in the Summary section of the alert.

For example, in our personal alerts we will use something like:

Machine {{$labels.instance}} is not reporting status via win-exporter. 
The machine could be offline or the service could be stopped.
Kyle Burkett
  • 1,375
  • 12
  • 28