Field value equal to 0 not recognized in a IF statetement

Hello all,

i have this float field:

{
"field_value" => 0.0
}

And this if statement in a logstash pipeline:

if [field_value] == 0 {
   mutate{ 
       add_field => {"is_zero" => "yes"}
   }
}
else {
   mutate{ 
       add_field => {"is_zero" => "no"}
   }
}

"is_zero" is always "no" in spite of "field_value" is 0.0. Sure i am missing something but i can't guess it

As far as I know, 0 and 0.0 are not the same. (Float vs Int) What happens if you change the if statement to look for 0.0?

Oh my god, i am stupid!. Thank you Vince

You are most likely not stupid, but rather got lost in the details. It happens to the best of us. Glad I could help.

1 Like