Fix @source_host when it comes from json_event

This is due to the change 1fc568e07d
which tries to get the @source value set sanely for json_event events which don't
have one.

However Logstash::Event unilaterally resets the @source_host when @source is set, which
is not what we want, at all. I have changed this so that @source_host is only set from
source in the case where @source_host was previously unset
This commit is contained in:
Tomas Doran 2012-10-26 15:55:00 +01:00
parent 1fc568e07d
commit fe1657a23c

View file

@ -15,6 +15,7 @@ class LogStash::Event
@cancelled = false @cancelled = false
@data = { @data = {
"@source_host" => false,
"@source" => "unknown", "@source" => "unknown",
"@tags" => [], "@tags" => [],
"@fields" => {}, "@fields" => {},
@ -83,11 +84,14 @@ class LogStash::Event
val = uri if uri val = uri if uri
if val.is_a?(URI) if val.is_a?(URI)
@data["@source"] = val.to_s @data["@source"] = val.to_s
@data["@source_host"] = val.host maybe_new_source_host = val.host
@data["@source_path"] = val.path @data["@source_path"] = val.path
else else
@data["@source"] = val @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
end # def source= end # def source=