In my currently implementation, I have wrapped code of both custom plugins inside begin...rescue block. What I want to achieve is - if there are any exceptions raised, I want to drop that event in a way that it never reaches output plugin.
Just tried above mentioned approach without luck! Logstash is forwarding the event to next plugin in chain. Is there any way to stop such events from propagating into the pipeline?
My code looks like below :
def encode(event)
<some code setting up dw>
begin
dw.write(clean_event(event), encoder)
rescue Avro::IO::AvroTypeError => avroTypeException
@logger.error(avroTypeException.message)
@logger.error("[ AvroSchema Mismatch ]: "+ event.get("[header][correlationId]"))
event.cancel
@logger.error("Event dropped")
rescue => genericException
@logger.error("Unknown Exception occurred - " + genericException.message)
@logger.error(genericException.backtrace.join("\n"))
event.cancel
@logger.error("Event dropped")
end
if @binary_encoded
@on_event.call(event, buffer.string)
else
@on_event.call(event, Base64.strict_encode64(buffer.string))
end
end
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.