Merge pull request #95 from dinomite/fbb619fd8355486e1d4ad68755972168502bcdca

Add filtering by fields to output plugins (LOGSTASH-392)
This commit is contained in:
Jordan Sissel 2012-02-02 22:32:03 -08:00
commit 11658e79d7

View file

@ -22,6 +22,10 @@ class LogStash::Outputs::Base < LogStash::Plugin
# Optional.
config :tags, :validate => :array, :default => []
# Only handle events with all of these fields.
# Optional.
config :fields, :validae => :array, :default => []
public
def initialize(params)
super
@ -64,6 +68,13 @@ class LogStash::Outputs::Base < LogStash::Plugin
end
end
if !@fields.empty?
if (event.fields.keys & @fields).size != @fields.size
@logger.debug(["Dropping event because type doesn't match #{@fields.inspect}", event])
return false
end
end
return true
end
end # class LogStash::Outputs::Base