[SOLVED] Usage of Logstash Ruby filter to calculate percentage


(Nandha Krishna) #1

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


(Muhammad Abbas (Mo Abbas)) #2

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


(Magnus Bäck) #6

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


(system) #7

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