<NME> environment.rb
<BEF> ADDFILE
<MSG> Merge pull request #119 from gja/add_fields_from_environment_variables

Added a filter to add fields from environment variables
<DFF> @@ -0,0 +1,26 @@
+require "logstash/filters/base"
+require "logstash/namespace"
+
+# Set fields from environment variables
+class LogStash::Filters::Environment < LogStash::Filters::Base
+  config_name "environment"
+  plugin_status "stable"
+
+  # 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.fields[field] = ENV[env]
+    end
+    filter_matched(event)
+  end # def filter
+end # class LogStash::Filters::Environment

Merge pull request #119 from gja/add_fields_from_environment_variables