Sha256: 57e73e2e76fc878fe25b2c80d8da543476249a949badfdb132f5a10c6fcf6fcf

Contents?: true

Size: 924 Bytes

Versions: 7

Compression:

Stored size: 924 Bytes

Contents

require "fluent/plugin/parser_grok"

module Fluent
  module Plugin
    class MultilineGrokParser < GrokParser
      Fluent::Plugin.register_parser("multiline_grok", self)

      desc "The regexp to match beginning of multiline"
      config_param :multiline_start_regexp, :string, default: nil

      def has_firstline?
        !!@multiline_start_regexp
      end

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

      def parse(text)
        @grok.parsers.each do |parser|
          parser.parse(text) do |time, record|
            if time and record
              yield time, record
              return
            end
          end
        end
        @default_parser.parse(text) do |time, record|
          record[@grok_failure_key] = "No grok pattern matched" if @grok_failure_key
          yield time, record
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fluent-plugin-grok-parser-2.1.6 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.1.5 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.1.4 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.1.3 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.1.2 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.1.1 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.1.0 lib/fluent/plugin/parser_multiline_grok.rb