From 52e1059ac78a0ae428a06a7bff9a611169366cb5 Mon Sep 17 00:00:00 2001 From: "John E. Vincent" Date: Wed, 29 Jun 2011 12:42:36 -0400 Subject: [PATCH 1/3] addding support to override sender in GELF message --- lib/logstash/outputs/gelf.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/logstash/outputs/gelf.rb b/lib/logstash/outputs/gelf.rb index 5e8a0ad70aa..2f19f44334a 100644 --- a/lib/logstash/outputs/gelf.rb +++ b/lib/logstash/outputs/gelf.rb @@ -18,6 +18,8 @@ class LogStash::Outputs::Gelf < LogStash::Outputs::Base # The GELF chunksize config :chunksize, :validate => :number, :default => 1420 + confg :sender, :validate => :string, :default => @source_host + # 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. @@ -70,7 +72,7 @@ def receive(event) end m["full_message"] = (event.message) - m["host"] = event["@source_host"] + m["host"] = @sender m["file"] = event["@source_path"] event.fields.each do |name, value| From dfd2a9b76788e1204eb1198ea737a050d2fc5f1c Mon Sep 17 00:00:00 2001 From: "John E. Vincent" Date: Wed, 29 Jun 2011 14:43:52 -0400 Subject: [PATCH 2/3] allowing override of gelf sender --- lib/logstash/outputs/gelf.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/logstash/outputs/gelf.rb b/lib/logstash/outputs/gelf.rb index 2f19f44334a..ab2cfe0afa5 100644 --- a/lib/logstash/outputs/gelf.rb +++ b/lib/logstash/outputs/gelf.rb @@ -18,7 +18,7 @@ class LogStash::Outputs::Gelf < LogStash::Outputs::Base # The GELF chunksize config :chunksize, :validate => :number, :default => 1420 - confg :sender, :validate => :string, :default => @source_host + 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 @@ -72,7 +72,8 @@ def receive(event) end m["full_message"] = (event.message) - m["host"] = @sender + + m["host"] = @sender.nil? ? event["@source_host"] : event.sprintf(@sender) m["file"] = event["@source_path"] event.fields.each do |name, value| From d38842a1f078818a5917183b611ce3fccdea5c64 Mon Sep 17 00:00:00 2001 From: "John E. Vincent" Date: Wed, 29 Jun 2011 22:04:55 -0700 Subject: [PATCH 3/3] Because i'm tired of hearing Rick Astley --- lib/logstash/outputs/gelf.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/logstash/outputs/gelf.rb b/lib/logstash/outputs/gelf.rb index ab2cfe0afa5..b955689fc68 100644 --- a/lib/logstash/outputs/gelf.rb +++ b/lib/logstash/outputs/gelf.rb @@ -18,7 +18,7 @@ class LogStash::Outputs::Gelf < LogStash::Outputs::Base # The GELF chunksize config :chunksize, :validate => :number, :default => 1420 - config :sender, :validate => :string + config :sender, :validate => :string, :default => "%{@source_host}" # 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 @@ -73,7 +73,7 @@ def receive(event) m["full_message"] = (event.message) - m["host"] = @sender.nil? ? event["@source_host"] : event.sprintf(@sender) + m["host"] = event.sprintf(@sender) m["file"] = event["@source_path"] event.fields.each do |name, value|