Puting multiple if conditionals into loop

Good morning.
So I'm into logstash filters code which contains tens of similar if conditionals like following:

if ("123456" == [ID]) {
  mutate {
    add_field => {
      "[fields][key1]" => "value1"
      "[fields][key2]" => "value2"

I was thinking about using ruby and array of hashes:
hashes = [
{"ID" => "123456", "key1" => "value1", "key2" => "value2"},
{"ID" => "234567", "key1" => "value1", "key2" => "value2"},
{"ID" => "345678", "key1" => "value1", "key2" => "value2"},
and so on ]

Is this a good approach and if it could I get any tips or links how to achieve that? Or if I took the wrong path could I get any advice how can achive my goal which is replacing tens if similar conditions with some friendly code?

You could use a translate filter. This has an example that might help.

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