Help Needed: Converting Numeric Aggregation Output to Boolean ("Up"/"Down") in Watcher Email Template

I’m configuring a watcher and email action in Elasticsearch to monitor the health status of multiple services and send email notifications with the status. Specifically, I need the status to display as either "Up" or "Down" in an HTML table format within the email. However, I’ve encountered an issue with formatting and interpreting the numeric output in the Mustache template.

"status": {
"bucket_script": {
"buckets_path": {
"up_count": "status_up._count",
"down_count": "status_down._count"
},
"script": "params.up_count > 0 ? 1 : 0" // Integer output for Up (1) or Down (0)
}
}

Template

{{#status.value}}Up{{/status.value}}{{^status.value}}Down{{/status.value}}

What am seeing is the value is coming as object {value=1.0}, but still its not working

Able to achieved using Transform using painless script, i refered anonmolies example given by elastic team

1 Like