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

**URL:** <https://discuss.elastic.co/t/i-am-trying-to-create-a-memory-usage-alert-in-kibana-but-its-showing-422-statuscode/319548>\
**Category:** Kibana\
**Tags:** elastic-stack-alerting\
**Created:** [November 22, 2022, 1:02pm UTC](https://discuss.elastic.co/t/i-am-trying-to-create-a-memory-usage-alert-in-kibana-but-its-showing-422-statuscode/319548 "2022-11-22T13:02:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jisha](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@jisha](https://discuss.elastic.co/u/jisha)\
**Post date:** [November 22, 2022, 1:02pm UTC](https://discuss.elastic.co/t/i-am-trying-to-create-a-memory-usage-alert-in-kibana-but-its-showing-422-statuscode/319548/1 "2022-11-22T13:02:08Z")

</div>

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\_usage_100).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\_usage_100, 'memory\_usage\_round': memory\_usage\_round, 'os': os, 'application': application, 'ip': ip];\n }).collect(Collectors.toList());"

Below shown is the error  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/c/6c9a0ce7526eb4a5285291fdd2d2d8a9a89fad38.png)

---

<div class="post-metadata">

**Author:** ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)\
**Post date:** [November 29, 2022, 4:03pm UTC](https://discuss.elastic.co/t/i-am-trying-to-create-a-memory-usage-alert-in-kibana-but-its-showing-422-statuscode/319548/2 "2022-11-29T16:03:04Z")

</div>

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:

```auto
{
  "some" : "example"
}

```

1. Perhaps the watch output without the problematic transform block (again, formatted so that it is readable)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 27, 2022, 4:04pm UTC](https://discuss.elastic.co/t/i-am-trying-to-create-a-memory-usage-alert-in-kibana-but-its-showing-422-statuscode/319548/3 "2022-12-27T16:04:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
