Sha256: 6cfa3530e818aa1771d1aa14e9631eaf25db5791c18bec42569ec7bd294c284b

Contents?: true

Size: 1010 Bytes

Versions: 8

Compression:

Stored size: 1010 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 |name_or_index, parser|
          parser.parse(text) do |time, record|
            if time and record
              record[@grok_name_key] = name_or_index if @grok_name_key
              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

8 entries across 8 versions & 1 rubygems

Version Path
fluent-plugin-grok-parser-2.6.2 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.6.1 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.6.0 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.5.1 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.5.0 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.4.0 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.3.0 lib/fluent/plugin/parser_multiline_grok.rb
fluent-plugin-grok-parser-2.2.0 lib/fluent/plugin/parser_multiline_grok.rb