Hi, I want to include these hostnames in my alert messages on Telegram. I created a label called HostName, leaving its value blank, and added it to the alert contact points. Here’s my alert:
{{ range .Alerts }}
iLO Alert
HostName: {{ .Labels.HostName }}
{{ end }}
However, I’m not getting the hostnames in the alerts, and I see this instead into Telegram message:
iLO Alert
HostName:
Can you guide me on how to solve this problem?"
you iterate over .Alerts which is a struct with two fields Firing
and Resolved
.
Try change your template to
{{ range .Alerts.Firing }}
:rotating_light: iLO Alert :rotating_light:
HostName: {{ .Labels.HostName }}
{{ end }}
I use your way!
and I get above alert!
Listen i define teh labels like this
because I read somewhere if i want to use dynamicly Labels values it must be empety!
so what do you think?!I think there is a mistake by me for this!
@sasanaalem, I see the label HostName
is returned by your Elastic query.
Query labels are also included in the .Labels
property of the Alert in the notification template.
In this case, you don’t need to create a custom HostName
label.
The issue may be that your custom HostName
label is empty, which overwrites the value of the HostName
query label. Removing the custom HostName
label should resolve it.
More info in in the Label types documentation.