Hi, I want to add some fields that will have the same values of others but with different names:
for Example the input json:
{"Environment" : "x", "Name" : "y"}
The output will be:
{"Environment" : "x", "Name" : "y", "environment" : "x ", "name" : "y"}
Because I have a lot of fields to add I tried to do some mapping before and use ruby:
ruby {
code => '
mapping = {"Environment":"environment", "Name": "name"}
mapping.each do |old_field, new_field|
old_field_val = event.get(old_field)
if old_field_val
event.set(new_field, old_field_val)
end
end
'
}
It seems like the event.get can't get variable but has to get string.
Is there any other way to do so?
Thanks