Sha256: 3ff8c340eeee9f3b7bbb4ff2ac62d2206a4d0d819556e4dae2fc5a49554a5660

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 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::Oui < 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 "oui"
  milestone 1
  
  # The source field to parse
  config :source, :validate => :string, :default => "message"

  # The target field to place all the data
  config :target, :validate => :string, :default => "oui"

  public
  def register
    # Add instance variables 
    require 'oui'
  end # def register

  public
  def filter(event)

    oui = OUI.find event[@source]
    if ! oui.nil?
      event[@target] = Hash.new
      oui.each do |key, value|
        event[@target][key.to_s] = value
      end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
logstash-filter-oui-2.0.4 lib/logstash/filters/oui.rb
logstash-filter-oui-2.0.2 lib/logstash/filters/oui.rb
logstash-filter-oui-2.0.1 lib/logstash/filters/oui.rb
logstash-filter-oui-0.1.5 lib/logstash/filters/oui.rb
logstash-filter-oui-0.1.4 lib/logstash/filters/oui.rb
logstash-filter-oui-0.1.3 lib/logstash/filters/oui.rb
logstash-filter-oui-0.1.2 lib/logstash/filters/oui.rb