How to add/rename fields recursively instead using mutate or instead doing one by one?

Hi All

How to add/rename fields recursively, instead doing one by one
Here is my dataset with message value as

[{
"Row ID" : 201,
"Order ID" : "CA-2017-105074",
"Order Date" : "6/24/2017",
"Segment" : "Consumer",
..
..
..
..
}, {
"Row ID" : 454,
"Order ID" : "CA-2017-147277",
"Segment" : "Test",
..
..
..
..

  }
  
  ]

I am using this in conf file

		split { field => "[message]" }
mutate {  
 add_field => {"Row ID" => "%{[message][Row ID]}"}
 add_field => {"Order ID" => "%{[message][Order ID]}"}
 add_field => {"Segment" => "%{[message][Segment]}"}
 }  

With this filter, i get right result
In my dataset i have close to 200 columns,
its very difficult to define the column name for each and every mutate for each field

How we can do this recursively using Ruby? To define all the names for each field in one go

Thanks

Does this help?

1 Like

wow, it works. Thanks

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