Hello,
I am trying data that looks like this
unwanted.field1
unwanted.field2
categories.colors.blue.t.type
First I need to remove every unwanted field, then I want to change categories.colors to only blue.t.type.
I can use a kv filter for to remove unwanted fileds, but I am unable to find an easy way to remove
catories.colors dynamically
I want
unwanted.field1
unwanted.field2
categories.colors.t.blue.type
categories.colors.t.red.type
to become
t.blue.type
t.red.type
My code
//ruby {
code => "
begin
keys = event.to_hash.keys
keys.each{|key|
if ( key =~ /m./ )
if key.start_with? '[categories][colors]'
#I don't know what should go in the event.set, how do I can a field name matching a pattern and doing a substring to get everything after the ''.t.''
event.set('key.substring something', event.remove(key))
I amd having a hard time doing a start, ruby doesnt seem to like [field][field] and I can't escape de dots either with a backslash..
I am starting to wonder if i am on the right path or is there an easier way?
Thank you,