I am using the following ruby filter to update the fields.
def filter(event)
keys = event.to_hash.keys
keys.each{|key|
if ( key.start_with? '_' and key != "_@timestamp")
value = event.get(key)
newkey = key.sub!(/^_/, '')
event.remove(key)
event.set(newkey , value)
elsif (key == "_@timestamp")
value = event.get(key)
event.set("@apptimestamp", Time.at(value))
event.remove(key)
end
}
return [event]
rescue Exception => e
event.set('logstash_ruby_exception', 'underscores: ' + e.message)
return [event]
end
The code duplicates fields starting with underscore, to fields not starting with underscore. But for some reason doesn't eliminate the one's starting with underscore. That is, event.remove doesn't work as expected. Any ideas?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.