Kapacitor alert message if else statement issue

Hi All,

I tried to check the value of one of my field on top of level warning.

I found a post but it does not work, i got this error “error calling eq: incompatible types for comparison” which due to state value comparison.

Basically i want if state=2, message show value:stopped and not 2 else value:disconnected.

Plus I still have the if for .level

Message=’{{ .Level}} - {{ .ID }}, {{ if eq (index .Fields “State”) 2 }} value: stopped {{else}} value:disconnected {{end}} , last {{ if eq .Level “WARNING” {{index .Fields “warn_duration”}} minutes. {{else}} {{index .Fields “crit_duration”}} minutes. {{ end}}’

Thank you in advance for any help
Assuming can support 2 if statement.

Fyi in case, case closed

In stream, added in eval, to convert value to string

Then slight modif in .message “2”