Sha256: b9b5a1c964cc8f4c6c7d720021b988d10d3644ad0024d25b9f6ad7ea56767e68

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

require 'fluent/plugin/parser_grok'

module Fluent
  class TextParser
    class MultilineGrokParser < GrokParser
      Plugin.register_parser('multiline_grok', self)

      desc 'The regexp to match beginning of multiline'
      config_param :multiline_start_regexp, :string, :default => nil

      def initialize
        super
      end

      def configure(conf={})
        super
      end

      def has_firstline?
        !!@multiline_start_regexp
      end

      def firstline?(text)
        @multiline_start_regexp && !!@grok.multiline_start_regexp.match(text)
      end

      def parse(text, &block)
        if block_given?
          @grok.parsers.each do |parser|
            parser.parse(text) do |time, record|
              if time and record
                yield time, record
                return
              end
            end
          end
        else
          @grok.parsers.each do |parser|
            parser.parse(text) do |time, record|
              if time and record
                return time, record
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fluent-plugin-grok-parser-1.0.1 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-1.0.0 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-0.3.1 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-0.3.0 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-0.2.0 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-0.1.0 lib/fluent/plugin/parser_multiline_grok.rb