In the documentation, there is this example of if else.
.message('{{ .ID }} is {{ if eq .Level "OK" }}alive{{ else }}dead{{ end }}: {{ index .Fields "emitted" | printf "%0.3f" }} points/10s.')
Makes sense. But if i’m trying to do {{ if eq .tagname “somevalue” }} it doesn’t work.
I cant find any documentation regarding “if … else” with tags or fields in string templates.
You can definitely string them together with an else if. My example is using the .Level tag but I think you might be able to change that to use your tag values, although to be honest I’ve not tried.
{{if eq .Level "CRITICAL"}}
some stuff
<!--END CRITICAL ALERT HTML-->
<!--Begin WARNING Alert-->
{{ else if eq .Level "WARNING"}}
some other stuff
<!-- End WARNING Alert Message-->
<!--OK ALERT HTML-->
{{ else}}
more stuff
{{end}}
You should be able to insert as many “else if” as you want. As i say though, not sure if it works with tag values like you want. If your message is working with tag values like that i would assume it should work but ya never know