Skip to content

Commit

Permalink
Merge pull request #93 from nickethier/feature/input-add_field
Browse files Browse the repository at this point in the history
implemented add_field within inputs
  • Loading branch information
jordansissel committed Jan 27, 2012
2 parents 9634be5 + b41d2be commit 1e11bab
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/logstash/inputs/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class LogStash::Inputs::Base < LogStash::Plugin
#return true
#end) # config :tag

# Add a field to an event
config :add_field, :validate => :hash, :default => {}

attr_accessor :params

public
Expand Down Expand Up @@ -110,6 +113,12 @@ def to_event(raw, source)
raise "unknown event format #{@format}, this should never happen"
end

@add_field.each do |field, value|
event[field] ||= []
event[field] = [event[field]] if !event[field].is_a?(Array)
event[field] << event.sprintf(value)
end

logger.debug(["Received new event", {:source => source, :event => event}])
return event
end # def to_event
Expand Down

0 comments on commit 1e11bab

Please sign in to comment.