I want to delete the fields which the value has a specific substring.
I have this code:
ruby {
code => "
event.each do |key, value|
if value =~ /substring/
event.delete(key)
end
end
"
}
I am getting a ruby exception on tags and I don't know why. Thanks!
One can not modify a hash while iterating it.
event.reject! { |_, value| value =~ /substring/ }
The above should do.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.