Sha256: f506605f157fa174a78915853e497bc004ea4d21c2588df7aded416fd9aa8323

Contents?: true

Size: 918 Bytes

Versions: 3

Compression:

Stored size: 918 Bytes

Contents

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

class LogStash::Filters::Ipcat < 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 'ipcat'

  config :source, validate: :string, required: true
  config :target, validate: :string, default: 'ipcat'

  public

  def register
    path = ::File.expand_path('../../../vendor/datacenters.csv', ::File.dirname(__FILE__))
    @datacenters = IPCat::Datacenters.new path
  end # def register

  public

  def filter(event)
    d = @datacenters.find(event[@source])
    event[@target] = d

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logstash-filter-ipcat-0.1.4 lib/logstash/filters/ipcat.rb
logstash-filter-ipcat-0.1.3 lib/logstash/filters/ipcat.rb
logstash-filter-ipcat-0.1.2 lib/logstash/filters/ipcat.rb