Hello @hext,
I think you’re close but how you evaluate the level and also you need to include that if else in the message, not the level definition. See thee example below as reference.
var data = stream
|from()...
// Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
data
|stats(10s)
.align()
|derivative('emitted')
.unit(10s)
.nonNegative()
|alert()
.id('node \'stream0\' in task \'{{ .TaskName }}\'')
.message('{{ .ID }} is {{ if eq .Level "OK" }}alive{{ else }}dead{{ end }}: {{ index .Fields "emitted" | printf "%0.3f" }} points/10s.')
.crit(lambda: "emitted" <= 100.0)
//Do normal processing of data
Alternatively, you might find this levelfield useful which creates an optional field key to add to the data, containing the alert level as a string:
Thank you for clarifying this. I was under the impression that if else statement were possible in the .Level definition, but what you’ve provided is a good work around.