Rounding float in ruby filter in logstash -


i using 'elapsed' logstash filter calculate time duration of event. need time in minutes instead of seconds, default in logstash. so, i'm using ruby filter conversion not able round float 2 decimal places inside ruby filter.

filter{  ruby{    code=>"event['elapsed.time']=event['elapsed.time']/60.0"  } } 

i tried use display format ".2f" doesn't work, because of quotes. using escape characters doesn't work either.

i tried .round(2) on float number, original value retained.

i had same thing far rounding goes. need wrap what's right of = in ().round(2) so:

(event['elapsed.time'] / 60.0).round(2)" 

for me, needed ensure field float start added mutate filter. result this:

filter{  mutate {    convert => [ "elapsed.time", "float" ]  }  ruby{    code=>"event['elapsed.time'] = (event['elapsed.time'] / 60.0).round(2)"  } } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -