Hello, I wanted to send the hostname of an alerted host with the e-mail, and I stumbled up on to use something like this in the alert description:
Host: {{ $values.B0.value.labels.host }}
But if an alert triggers, it will just write the literal “{{ $values.B0.value.labels.host }}” instead of the hostname. Trying just $values.B0.labels.host gave me a “<no value”
I heard there are alert templates, but I just want to add one variable and not re-write the whole alert e-mail.
Hi @madddogg2406,
If you are using Reduce expression in your alert try this:
{{ $values.B.Labels.host }}
If you are using Classic condition expression try this:
{{ $values.B0.Labels.host }}
https://localhost:3000/t/how-to-use-alert-message-templates-in-grafana/67537/129?u=ldrascic
Best regards,
ldrascic
Ah okay I will try this. Is a Threshold also a B0 or a B?
Hi! If it helps the documentation for this can be found here Templating labels and annotations | Grafana documentation, including for Classic Conditions.
To answer the question it is just Classic Conditions that use B0
, B1
, etc. Reduce, Threshold and Math expressions do not. This is because each individual Classic Condition can contain multiple conditions.