Hi,
I have never used ruby before, or logstash.
i have been trying to modify nested JSON field using ruby. JSON looks like below.
{ "a" : { "b" : "c=d; e=f; g=h" }
My end goal is to remove e=f from the nested key b. But to reach that, my first step was to see if i can replace or even access the field "a". but logger.info doesn't seem to print anything.
filter {
ruby {
code => "
logger.info(event.get("[a]")
"
}
}
Somethings i tried..
filter {
ruby {
code => '
bField = event.get("[a][b]")
if bField
bField.gsub!("e=[^;]+;?", "") # Replace e=f; field and its value along with trailing semicolon if any
event.set("[a][b]", bField)
end
'
}
}
Any help is very much appreciated