Within my input on one of my watches I have :
"aggs": { "e2e_av_time": { "avg": { "field" : "e2e_time" } }
(Note that e2e_time is a long within my mapping.)
I then use it later in the action:
> "text": "The average e2e time has dropped to {{ctx.payload.aggregations.e2e_av_time.value}}ms"
However in some cases this is producing 8 decimal places from whole integer numbers. Simulation Output:
"text": "The average e2e time has dropped to 313.922512715544ms"`
The maximum number of decimal places I would want is 2 and preferably none! In order to fix this I tried to use a script :
"aggs": { "e2e_av_time": { "avg": { "script": { "inline": "return (int) Math.ceil(doc['e2e_time'].value)" } } } }
I have also tried variations without casting and with Math.round() and .round(). I'm hoping that someone can tell me where I'm going wrong? Am i pointing to the wrong area of the payload? Thanks in advance.