Sha256: 9c0a2aa260511e5682bed7053d3ec07fdca59566b4469c48dc0e8b41b8c8f1c3

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

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

# This example filter will replace the contents of the default 
# message field with whatever you specify in the configuration.
#
# It is only intended to be used as an example.
class LogStash::Filters::Example < LogStash::Filters::Base

  # Setting the config_name here is required. This is how you
  # configure this filter from your Logstash config.
  #
  # filter {
  #   example {
  #     message => "My message..."
  #   }
  # }
  #
  config_name "example"
  
  # Replace the message with this value.
  config :message, :validate => :string, :default => "Hello World!"
  

  public
  def register
    # Add instance variables 
  end # def register

  public
  def filter(event)

    if @message
      # Replace the event message with our message as configured in the
      # config file.
      event["message"] = @message
    end

    # filter_matched should go in the last line of our successful code
    filter_matched(event)
  end # def filter
end # class LogStash::Filters::Example

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
logstash-filter-example-2.0.2 lib/logstash/filters/example.rb
logstash-filter-example-2.0.1 lib/logstash/filters/example.rb
logstash-filter-mixpanel-0.1.0 lib/logstash/filters/mixpanel.rb
logstash-filter-example-0.1.4 lib/logstash/filters/example.rb
logstash-filter-example-0.1.3 lib/logstash/filters/example.rb