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
Post a Comment