How to customise alert messages for Nodes Stats API

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

Describe the issue:
I’m trying to create a Monitor that will send an alert if JVM usage for one or more of the nodes is above a threshold.
I’m able to detect this condition and send a static message, e.g. “One or more nodes jvm percentage is above X%”, but I would like to extract the JVM usage percentage from the Nodes Stats API and include this in the message. I’m not able to do this via Mustache.


I’m creating a new Per Cluster Metrics Monitor using the Nodes Stats API.

I’m able to detect the JVM usage issue using this Trigger condition:

List nodes_with_jvm_pressure = new ArrayList();

for (key in ctx.results[0].nodes.keySet()) {
    if (ctx.results[0].nodes[key].jvm.mem.heap_used_percent > 40) {

if (nodes_with_jvm_pressure.size() > 0) {
  return true

But I’m not sure how to create the Action to select the nodes.<NODE_ID>.jvm.mem.heap_used_percent value and include this in my message.

The problem seems to be that Nodes Stats doesn’t return a list so I can loop over it with e.g.

something here

I’m not sure how to loop over the nodes JSON object, especially because NODE_ID values can be whatever (I don’t want to hardcode them).

Can you help? Thanks.

Relevant Logs or Screenshots: