I am trying to create a memory usage alert in kibana but its showing 422 statuscode

Hi ,
i am trying to create a memory usage alert in kibana but its showing 422 statuscode,
while i define & return application details. This is the source which i used where error is showing up.
if i removed application details from the source its working fine without showing the application name in response

"source": "def hosts=data.mysearch.aggregations.bucketAgg.buckets;\n return hosts.stream().filter(h->{\n def memory_usage=h.metricAgg.value;\n return memory_usage>0.40;\n }).map(h->{\n def memory_usage=h.metricAgg.value;\n def memory_usage_round=BigDecimal.valueOf(memory_usage100).setScale(2, RoundingMode.HALF_EVEN);\n def application=h.APPLICATION.buckets.key;\n def os=h.OS.buckets[0].key;\n def ip=h.IP.buckets[0].key; \n return['host': h.key, 'memory_usage': memory_usage100, 'memory_usage_round': memory_usage_round, 'os': os, 'application': application, 'ip': ip];\n }).collect(Collectors.toList());"

Below shown is the error
image

It is going to be hard to help without:

  1. contents of entire Watch
  2. watch contents formatted properly (with the Pre-formatted text option in the toolbar) to make it look like this:
{
  "some" :  "example"
}
  1. Perhaps the watch output without the problematic transform block (again, formatted so that it is readable)