Sha256: cb6852239947253a6b8b97b99aad0fb63455171a498f1de46943f247827882c2

Contents?: true

Size: 700 Bytes

Versions: 2

Compression:

Stored size: 700 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

2 entries across 2 versions & 1 rubygems

Version Path
logstash-filter-environment-0.1.2 lib/logstash/filters/environment.rb
logstash-filter-environment-0.1.1 lib/logstash/filters/environment.rb