Sha256: 3b0919d7c6a5c73ec413d12ecdae9944018b16559d2115477d70173bd35cd36d

Contents?: true

Size: 843 Bytes

Versions: 3

Compression:

Stored size: 843 Bytes

Contents

# encoding: utf-8
require "logstash/filters/base"
require "logstash/namespace"

# The clone filter is for duplicating events.
# A clone will be made for each type in the clone list.
# The original event is left unchanged.
class LogStash::Filters::Clone < LogStash::Filters::Base

  config_name "clone"

  # A new clone will be created with the given type for each type in this list.
  config :clones, :validate => :array, :default => []

  public
  def register
    # Nothing to do
  end

  public
  def filter(event)
    @clones.each do |type|
      clone = event.clone
      clone.set("type", type)
      filter_matched(clone)
      @logger.debug("Cloned event", :clone => clone, :event => event)

      # Push this new event onto the stack at the LogStash::FilterWorker
      yield clone
    end
  end

end # class LogStash::Filters::Clone

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logstash-filter-clone-3.0.2 lib/logstash/filters/clone.rb
logstash-filter-clone-3.0.1 lib/logstash/filters/clone.rb
logstash-filter-clone-3.0.0 lib/logstash/filters/clone.rb