Hi, I try to delete an array element using a regexp, But code isn't run.
Imput json:
`{"test":"The http module allows to expose\nThe http module allows to expose\ncamp:using asynchronous communication\nusing asynchronous communication"}`
In this case, I want to delete any element that has "http module" in value.
Pipiline:
input{
stdin{
codec => json {
}
}
}
filter{
ruby{
code => '
matches = event.get("test").split("\n")
matches.each_index{ |x|
if matches[x] =~ ".*http module.*"
else
matches.delete_at(x)
end
}
matches.each_index{ |x|
event.set("line#{x+1}", matches[x])
}
'
}
}
output {
stdout {
codec => rubydebug
}
}
I want the result:
line1:using asynchronous communication
line1:using asynchronous communication