mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
Merge pull request #231 from bobtfish/fix_source_host
Fix @source_host when it comes from json_event
This commit is contained in:
commit
9bf5efdfcc
1 changed files with 7 additions and 3 deletions
|
@ -16,6 +16,7 @@ class LogStash::Event
|
|||
@cancelled = false
|
||||
|
||||
@data = {
|
||||
"@source_host" => false,
|
||||
"@source" => "unknown",
|
||||
"@tags" => [],
|
||||
"@fields" => {},
|
||||
|
@ -91,16 +92,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=
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue