[SOLVED] Usage of Logstash Ruby filter to calculate percentage

I want to know how to calculate percentage using the logstash ruby filter.

I have tried this code and it did not work.

code => "event.set('[ratio_match]', (event.get('A')/event.get('B')*100))"

Kindly help me with where I'm going wrong.

Thanks,
Nandha Krishna

Try this one
code => 'event.set("[ratio_match]", [event.get("[OUTSTANDING_COUNT]" / event.get("[ITEM_COUNT]") * 100 ] )'

It looks like you're not closing the first event.get() call (i.e. there's a ")" missing before the "/").

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