Sha256: 1332f4215ac14ab1e6033f2acef7cfb8b2854423f723a1b59558718d554b6b31

Contents?: true

Size: 873 Bytes

Versions: 5

Compression:

Stored size: 873 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)
    return unless filter?(event)
    @clones.each do |type|
      clone = event.clone
      clone["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

5 entries across 5 versions & 1 rubygems

Version Path
logstash-filter-clone-2.0.0 lib/logstash/filters/clone.rb
logstash-filter-clone-1.0.0 lib/logstash/filters/clone.rb
logstash-filter-clone-0.1.5 lib/logstash/filters/clone.rb
logstash-filter-clone-0.1.4 lib/logstash/filters/clone.rb
logstash-filter-clone-0.1.3 lib/logstash/filters/clone.rb