Scripted field to convert 1024 Bytes to 1000 metric bytes

In 6.4.2 I have a scripted filed that converts 1024Bytes to 1000Bytes as that is how we bill by this is the script that was working in 6.4.2

(doc['total_usage'].value *1000000000) * Math.pow(1.024, Math.floor(Math.log(doc['total_usage'].value*1000000000)/Math.log(1000)))

When I try to do this in 7.0.0 I get an error rendering . Just says shards failed
What is the right way to do this in scripted field for 7.0.0?

Thanks

Got it working by adding a validator I guess the problem is that the new kibana is strict if the size is 0 it fails where as 6.4.3 will just ignore and process the next value. Here is the working version of the above:

def output = 0;
List varlist= ['total_usage']; for (s in varlist) { if (doc[s].size()>0) {output = (doc['total_usage'].value *1000000000) * Math.pow(1.024, Math.floor(Math.log(doc['total_usage'].value*1000000000)/Math.log(1000))) }}
return output;

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