Unable to use if condition and calculate percenatge inside ruby code

I am trying to first filter my data with only 3 KPI and only with hostname which domain is ".xxx.com".
then I want to calculate percentage from value_current and value_max columns.
mutate {convert => ["value_current", "integer"]}
mutate {convert => ["value_max", "integer"]}
if [kpi_name] in ["DiskFilesystemUtilization","CpuUtilization","MemoryUtilization"]{
if ("xxxx.com" in [host_name]){

                                    code => 'event.set("[Percentage]",[event.get("[value_current]") / event.get("[value_max]") * 100 ] )'


This does not look at filter and sending the data as it is.

It works only if I put if condition in output section of logstash. but that takes lot of time to first calculate percentage and then filter with 3 KPI and host names.

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