# How to Round up the result to the nearest integer

**URL:** <https://discuss.elastic.co/t/how-to-round-up-the-result-to-the-nearest-integer/248897>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [September 17, 2020, 1:55am UTC](https://discuss.elastic.co/t/how-to-round-up-the-result-to-the-nearest-integer/248897 "2020-09-17T01:55:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karrie\_Koo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karrie_koo/32/52576_2.png) [@Karrie\_Koo](https://discuss.elastic.co/u/Karrie_Koo)\
**Post date:** [September 17, 2020, 1:55am UTC](https://discuss.elastic.co/t/how-to-round-up-the-result-to-the-nearest-integer/248897/1 "2020-09-17T01:55:02Z")

</div>

For the log text,  
{{heapUsedPct.0}} \<= This field shows the result with many decimal places, I want to round up to the nearest integer, but how can I do it?

{  
"trigger": {  
"schedule": {  
"interval": "15m"  
}  
},  
"input": {  
"search": {  
"request": {  
"search\_type": "query\_then\_fetch",  
"indices": [  
"eap\_wls\_gc\_12c\*",  
"_:eap\_wls\_gc\_12c_"  
],  
"types": ,  
"body": {  
"size": 10,  
"query": {  
"bool": {  
"must": [  
{  
"range": {  
"@timestamp": {  
"gte": "now-15m/m",  
"lte": "now"  
}  
}  
},  
{  
"range": {  
"heapUsedPct": {  
"gte": 90,  
"lte": 100  
}  
}  
},  
{  
"regexp": {  
"wlsdomain.keyword": "(._cms._)|(._phr._)|(._mshr._)"  
}  
}  
]  
}  
},  
"sort": [  
{  
"@timestamp": {  
"order": "desc"  
}  
}  
]  
}  
}  
}  
},  
"condition": {  
"compare": {  
"ctx.payload.hits.total": {  
"gt": 0  
}  
}  
},  
"actions": {  
"log\_error": {  
"transform": {  
"script": {  
"source": "\t\t\t def docs = ;\n\t\t\t for (hit in ctx.payload.hits.hits) {\n\t\t\t def update = hit['\_source'];\n\t\t\t // Pattern to parse the date/timestamp input.\n\t\t\t DateTimeFormatter input = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");\n\t\t\t ZonedDateTime date = ZonedDateTime.parse(hit.\_source['@timestamp'], input.withZone(ZoneId.of("UTC"))).plusHours(8);\n\t\t\t // Pattern to format the parsed date.\n\t\t\t DateTimeFormatter output = DateTimeFormatter.ofPattern("yyyy-MM-dd.HH:mm:ss.SSS");\n\t\t\t update['logDate'] = date.format(output);\n\t\t\t docs.add(update);\n\t\t}\n return ['exceptions\_details': docs];",  
"lang": "painless"  
}  
},  
"logging": {  
"category": "watcher.logging.bppm.MAJOR",  
"level": "info",  
"text": "Found {{ctx.payload.exceptions\_details.size}} exceptions in the server logs.{{#ctx.payload.exceptions\_details}}\n\n[MAJOR] {{@timestamp}} {{host.name}} {{wlsdomain}} {{wlsname}} Heap Usage is {{heapUsedPct.0}}% (CMSICACC){{/ctx.payload.exceptions\_details}}"  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 17, 2020, 2:02am UTC](https://discuss.elastic.co/t/how-to-round-up-the-result-to-the-nearest-integer/248897/2 "2020-09-17T02:02:30Z")

</div>

Please format your code/logs/config using the `</>` button, or markdown style back ticks. It helps to make things easy to read which helps us help you 🙂

---

<div class="post-metadata">

**Author:** ![Karrie\_Koo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karrie_koo/32/52576_2.png) [@Karrie\_Koo](https://discuss.elastic.co/u/Karrie_Koo)\
**Post date:** [September 18, 2020, 2:01am UTC](https://discuss.elastic.co/t/how-to-round-up-the-result-to-the-nearest-integer/248897/3 "2020-09-18T02:01:50Z")

</div>

thanks

---

<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:** [October 16, 2020, 2:02am UTC](https://discuss.elastic.co/t/how-to-round-up-the-result-to-the-nearest-integer/248897/4 "2020-10-16T02:02:13Z")

</div>

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