Skip to content

Commit

Permalink
Fixes elastic#880 - Adds support for sending tags in gelf output
Browse files Browse the repository at this point in the history
This adds tag support to the gelf output.

It adds a new option called ship_tags, set to true by default, when
sends all tags as a new field called _tags to GELF. Tags are converted
from an array to a comma separated list.
  • Loading branch information
jamtur01 committed Jan 26, 2013
1 parent 35acfa5 commit 682d517
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/logstash/outputs/gelf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class LogStash::Outputs::Gelf < LogStash::Outputs::Base
# messages.
config :ship_metadata, :validate => :boolean, :default => true

# Ship tags within events. This will cause logstash to ship the tags of an
# event as the field _tags.
config :ship_tags, :validate => :boolean, :default => true

# Ignore these fields when ship_metadata is set. Typically this lists the
# fields used in dynamic values for GELF fields.
config :ignore_metadata, :validate => :array, :default => [ "severity", "source_host", "source_path", "short_message" ]
Expand Down Expand Up @@ -156,6 +160,10 @@ def receive(event)
end
end

if @ship_tags
m["_tags"] = event.tags.join(', ')
end

if @custom_fields
@custom_fields.each do |field_name, field_value|
m["_#{field_name}"] = field_value unless field_name == 'id'
Expand Down

0 comments on commit 682d517

Please sign in to comment.