lib/logstash/inputs/nsq.rb in logstash-input-nsq-2.0.1 vs lib/logstash/inputs/nsq.rb in logstash-input-nsq-2.0.2
- old
+ new
@@ -12,10 +12,11 @@
config :topic, :validate => :string, :default => 'testtopic'
config :max_in_flight, :validate => :number, :default => 100
config :tls_v1, :validate => :boolean, :default => false
config :tls_key, :validate => :string
config :tls_cert, :validate => :string
+ config :multi_events, :validate => :boolean, :default => false
public
def register
@logger.info('Registering nsq', :channel => @channel, :topic => @topic, :nsqlookupd => @nsqlookupd)
if @tls_key and @tls_cert
@@ -57,16 +58,24 @@
end # def run
private
def queue_event(body, output_queue)
begin
- #@logger.info('processing:', :body => body)
- event = LogStash::Event.new("message" => body)
- decorate(event)
- output_queue << event
- rescue => e # parse or event creation error
- @logger.error('Failed to create event', :message => "#{body}", :exception => e,
- :backtrace => e.backtrace)
+ if @multi_events
+ events = body.split("\n")
+ events.each do |ev|
+ event = LogStash::Event.new("message" => ev)
+ decorate(event)
+ output_queue << event
+ end
+ else
+ event = LogStash::Event.new("message" => body)
+ decorate(event)
+ output_queue << event
+ end
+ rescue => e # parse or event creation error
+ @logger.error('Failed to create event', :message => "#{body}", :exception => e, :multi_events => @multi_events,
+ :backtrace => e.backtrace)
end # begin
end # def queue_event
public
def stop