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 8ec3fc5 commit 7283f0d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/logstash/codecs/multiline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ class LogStash::Codecs::Multiline < LogStash::Codecs::Base
# max_lines.
config :max_bytes, :validate => :bytes, :default => "10 MiB"

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

public
def register
require "grok-pure" # rubygem 'jls-grok'
Expand Down Expand Up @@ -163,7 +166,8 @@ def register
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 @@ -211,7 +215,7 @@ def do_previous(text, matched, &block)
end

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

def over_maximun_bytes?
Expand Down

0 comments on commit 7283f0d

Please sign in to comment.