From 5ed8f75fe185b870b47c27268e134733b83324a1 Mon Sep 17 00:00:00 2001 From: sxmichael Date: Sun, 29 Nov 2015 17:58:37 +0200 Subject: [PATCH] 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. --- lib/logstash/codecs/multiline.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/logstash/codecs/multiline.rb b/lib/logstash/codecs/multiline.rb index 9f633c9..076fe40 100644 --- a/lib/logstash/codecs/multiline.rb +++ b/lib/logstash/codecs/multiline.rb @@ -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 @@ -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) @@ -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?