Sha256: 867ffbdd36d9a57e927591d812b21f956c9da403be6fadfb4dd72f69c94804e8

Contents?: true

Size: 698 Bytes

Versions: 1

Compression:

Stored size: 698 Bytes

Contents

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


# Set fields from environment variables
class LogStash::Filters::Environment < LogStash::Filters::Base
  config_name "environment"
  milestone 1

  # Specify a hash of fields to the environment variable
  # A hash of matches of field => environment variable
  config :add_field_from_env, :validate => :hash, :default => {}

  public
  def register
    # Nothing
  end # def register

  public
  def filter(event)
    return unless filter?(event)
    @add_field_from_env.each do |field, env|
      event[field] = ENV[env]
    end
    filter_matched(event)
  end # def filter
end # class LogStash::Filters::Environment

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-filter-environment-0.1.0 lib/logstash/filters/environment.rb