I would like create new events on some conditionals. Because the new events should only take a few fields, it would be easier to build up from scratch and add fileds like @timestamp and my fields I would like to store than deleting all not needed fields afterwards.
Then I would like to add the array of events to the return array of filter(event) function.
I have the same requirement and I was able to find something that seems to work. The following filter example generates 2 new events (beside the original one):
filter {
ruby {
code => "
require 'pry'
generated = LogStash::Event.new
generated.set('somefield', 'somevalue')
new_event_block.call(generated)
anotherone = LogStash::Event.new({'message' => 'withsomedata'})
anotherone.set('other', 'need to set more data')
new_event_block.call(anotherone)
"
}
}
Ruby's pretty new to me though, so if there's any good reason not to do it like this, some feedback would be much appreciated.
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.