Script - round an average

Hello,

In Kibana, i want to display the average of a field in Metric Vizualization

Average value : 24573.222

But the display don't change, it still show 2453.222

I even try this but it still don't work :

{

 "script": {

   "inline": "def nb = 0; while(nb < doc['nbr_ligne'].value){nb++} return nb",

   "lang": "painless"

 }

}

Is there any way to have an average without decimal?

Thanks

EDIT :

I try : Math.round(doc['nbr_ligne'].value), and it don't work too.

Any one have a solution?

Your script operates on each individual document, not on all the values accross all docs matching your aggregation. To have a script run on all the values collected, you need to use a scripted metric aggregation. However, that is not yet available in kibana: https://github.com/elastic/kibana/issues/2646

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