Sha256: 097b91cbad7c29a94a275a311b109a11bb05848ed6eb618c75aa43f98a11e9de

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

class Fluent::GrepOutput < Fluent::Output
  Fluent::Plugin.register_output('grep', self)

  config_param :input_key, :string
  config_param :regexp, :string, :default => nil
  config_param :exclude, :string, :default => nil
  config_param :tag, :string, :default => nil
  config_param :add_tag_prefix, :string, :default => 'grep'

  def configure(conf)
    super

    @input_key = @input_key.to_s
    @regexp = Regexp.compile(@regexp) if @regexp
    @exclude = Regexp.compile(@exclude) if @exclude
  end

  def emit(tag, es, chain)
    emit_tag = @tag ? @tag : "#{@add_tag_prefix}.#{tag}"

    es.each do |time,record|
      value = record[@input_key]
      next if @regexp and !@regexp.match(value)
      next if @exclude and @exclude.match(value)
      Fluent::Engine.emit(emit_tag, time, record)
    end

    chain.next
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-grep-0.0.1 lib/fluent/plugin/out_grep.rb