class LogStash::Filters::Environment
This filter stores environment variables as subfields in the `@metadata` field. You can then use these values in other parts of the pipeline.
Adding environment variables is as easy as:
filter { environment { add_metadata_from_env => { "field_name" => "ENV_VAR_NAME" } } }
Accessing stored environment variables is now done through the `@metadata` field:
["@metadata"]["field_name"]
This would reference field `field_name`, which in the above example references the `ENV_VAR_NAME` environment variable.
IMPORTANT: Previous versions of this plugin put the environment variables as fields at the root level of the event. Current versions make use of the `@metadata` field, as outlined. You have to change `add_field_from_env` in the older versions to `add_metadata_from_env` in the newer version.
Public Instance Methods
filter(event)
click to toggle source
# File lib/logstash/filters/environment.rb, line 50 def filter(event) @add_metadata_from_env.each do |field, env| event.set("[@metadata][#{field}]", ENV[env]) end filter_matched(event) end
register()
click to toggle source
# File lib/logstash/filters/environment.rb, line 45 def register # Nothing end