Skip to content

Commit 7283f0d

Browse files
sxmichaelMichael Gelfand
authored andcommitted
Support for not splitting the original message added
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.
1 parent 8ec3fc5 commit 7283f0d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/logstash/codecs/multiline.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ class LogStash::Codecs::Multiline < LogStash::Codecs::Base
126126
# max_lines.
127127
config :max_bytes, :validate => :bytes, :default => "10 MiB"
128128

129+
# Whether to split original message to lines.
130+
config :split_original, :validate => :boolean, :default => true
131+
129132
public
130133
def register
131134
require "grok-pure" # rubygem 'jls-grok'
@@ -163,7 +166,8 @@ def register
163166
def decode(text, &block)
164167
text = @converter.convert(text)
165168

166-
text.split("\n").each do |line|
169+
lines = @split_original ? text.split("\n") : [text]
170+
lines.each do |line|
167171
match = @grok.match(line)
168172
@logger.debug("Multiline", :pattern => @pattern, :text => line,
169173
:match => !match.nil?, :negate => @negate)
@@ -211,7 +215,7 @@ def do_previous(text, matched, &block)
211215
end
212216

213217
def over_maximun_lines?
214-
@buffer.size > @max_lines
218+
@buffer.size >= @max_lines
215219
end
216220

217221
def over_maximun_bytes?

0 commit comments

Comments
 (0)