Skip to content

Commit 5ed8f75

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 03f6935 commit 5ed8f75

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/logstash/codecs/multiline.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ module LogStash module Codecs class Multiline < LogStash::Codecs::Base
132132
# auto_flush_interval. No default. If unset, no auto_flush. Units: seconds
133133
config :auto_flush_interval, :validate => :number
134134

135+
# Whether to split original message to lines.
136+
config :split_original, :validate => :boolean, :default => true
137+
135138
public
136139

137140
def register
@@ -188,7 +191,9 @@ def accept(listener)
188191

189192
def decode(text, &block)
190193
text = @converter.convert(text)
191-
text.split("\n").each do |line|
194+
195+
lines = @split_original ? text.split("\n") : [text]
196+
lines.each do |line|
192197
match = @grok.match(line)
193198
@logger.debug("Multiline", :pattern => @pattern, :text => line,
194199
:match => !match.nil?, :negate => @negate)
@@ -263,7 +268,7 @@ def do_previous(text, matched, &block)
263268
end
264269

265270
def over_maximum_lines?
266-
@buffer.size > @max_lines
271+
@buffer.size >= @max_lines
267272
end
268273

269274
def over_maximum_bytes?

0 commit comments

Comments
 (0)