How to Round up the result to the nearest integer

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}}"
}
}
}
}

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 :slight_smile:

thanks

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