Skip to content

Commit

Permalink
Support for not splitting the original message added
Browse files Browse the repository at this point in the history
Added split_original config param (default: true), when true - splits the original message to multiple lines by '\n'; when false - passes original message as is.
over_maximun_lines check changed from 'greater then' to 'greater or equal': setting max_lines = X actually produced message blocks of X+1 messages due to strict "greater than" sign.
  • Loading branch information
sxmichael authored and Michael Gelfand committed Aug 6, 2016
1 parent 03f6935 commit 5ed8f75
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/logstash/codecs/multiline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ module LogStash module Codecs class Multiline < LogStash::Codecs::Base
# auto_flush_interval. No default. If unset, no auto_flush. Units: seconds
config :auto_flush_interval, :validate => :number

# Whether to split original message to lines.
config :split_original, :validate => :boolean, :default => true

public

def register
Expand Down Expand Up @@ -188,7 +191,9 @@ def accept(listener)

def decode(text, &block)
text = @converter.convert(text)
text.split("\n").each do |line|

lines = @split_original ? text.split("\n") : [text]
lines.each do |line|
match = @grok.match(line)
@logger.debug("Multiline", :pattern => @pattern, :text => line,
:match => !match.nil?, :negate => @negate)
Expand Down Expand Up @@ -263,7 +268,7 @@ def do_previous(text, matched, &block)
end

def over_maximum_lines?
@buffer.size > @max_lines
@buffer.size >= @max_lines
end

def over_maximum_bytes?
Expand Down

0 comments on commit 5ed8f75

Please sign in to comment.