diff --git a/lib/logstash/event.rb b/lib/logstash/event.rb index 09b314981..f5a60648d 100644 --- a/lib/logstash/event.rb +++ b/lib/logstash/event.rb @@ -15,6 +15,7 @@ class LogStash::Event @cancelled = false @data = { + "@source_host" => false, "@source" => "unknown", "@tags" => [], "@fields" => {}, @@ -78,16 +79,19 @@ class LogStash::Event public def source; @data["@source"]; end # def source - def source=(val) + def source=(val) uri = URI.parse(val) rescue nil val = uri if uri if val.is_a?(URI) @data["@source"] = val.to_s - @data["@source_host"] = val.host + maybe_new_source_host = val.host @data["@source_path"] = val.path else @data["@source"] = val - @data["@source_host"] = val + maybe_new_source_host = val + end + if !@data["@source_host"] + @data["@source_host"] = maybe_new_source_host end end # def source=