Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gelf sender override #30

Merged
merged 3 commits into from
Jun 30, 2011
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/logstash/outputs/gelf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class LogStash::Outputs::Gelf < LogStash::Outputs::Base
# The GELF chunksize
config :chunksize, :validate => :number, :default => 1420

config :sender, :validate => :string

# The GELF message level. Dynamic values like %{level} are permitted here;
# useful if you want to parse the 'log level' from an event and use that
# as the gelf level/severity.
Expand Down Expand Up @@ -70,7 +72,8 @@ def receive(event)
end

m["full_message"] = (event.message)
m["host"] = event["@source_host"]

m["host"] = @sender.nil? ? event["@source_host"] : event.sprintf(@sender)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be better written by setting the default in the sender config:

config: sender, :validate => :string, :default => "%{@source_host}"

Then:
m["host"] = event.sprintf(@sender)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JUMP ON IT.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never gonna give you up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never gonna let you down.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never gonna run around and desert you.

m["file"] = event["@source_path"]

event.fields.each do |name, value|
Expand Down