Logstash iterate through loop

if [field2] == 10 {
        mutate { replace => { "field2" => "1" } }
}
if [field2] == 11 {
        mutate { replace => { "field2" => "2" } }
}
if [field2] == 12 {
        mutate { replace => { "field2" => "3" } }
}

I have to check conditions up to 20 starting from 10 and replace the field value with a new one that is in serial order, How can I iterate through the loop?

Use a translate filter?

1 Like

I would opt for a ruby filter:

filter {
     ruby {
        code => "event.set('field2',event.get('field2')-9)
          }
       }

This is not working.

What is not working? What does your configuration look like?