Discrepancies when dividing a result using JSON input

I'm using Kibana 6.5.4 and I'm trying to create a simple metric..
I want to sum inbound bites, so I create the metric, I use Sum as aggregation and in field I put the correct field ("server_inbound_bytes"). The result is correct, but is in bytes (13,198,284,718,586, for example).
If I want to show it in GB, I'd devide it by 1024^3 (1073741824), so what I did is to use "JSON input" and there I write:
"{ "script" : "doc['server_inbound_bytes'].value / 1073741824 "}"
With that I'd expect to get 12,291, but I get 203.
Any clues on where is the problem?
My guess is that it divides by 1024^3 each single value (some of them are just a coupe of bytes and the result is taken as zero, and basically this an accumulated error.
If that is the case, how should I do it in order to divide the final result (13,198,284,718,586) and not each value before to sum it?

The easier solution for what you're trying to accomplish is probably just to use the "bytes" field formatter in the index pattern settings. Have you tried this?

LOL. After 5 or 6 years using Kibana, this is the first time I change something in the field formatter.
That did the trick.

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