mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
- Allow fields which are not arrays (syslog input generates them)
https://logstash.jira.com/browse/LOGSTASH-113
This commit is contained in:
parent
7d35def7e7
commit
3dfa25f316
1 changed files with 11 additions and 2 deletions
|
@ -74,9 +74,18 @@ class LogStash::Outputs::Gelf < LogStash::Outputs::Base
|
|||
m["file"] = event["@source_path"]
|
||||
|
||||
event.fields.each do |name, value|
|
||||
next if value == nil or value.empty?
|
||||
next if value == nil
|
||||
name = "_id" if name == "id" # "_id" is reserved, so use "__id"
|
||||
m["_#{name}"] = (value.length == 1) ? value.first : value
|
||||
if !value.nil?
|
||||
if value.is_a?(Array)
|
||||
# collapse single-element arrays, otherwise leave as array
|
||||
m["_#{name}"] = (value.length == 1) ? value.first : value
|
||||
else
|
||||
# Non array values should be presented as-is
|
||||
# https://logstash.jira.com/browse/LOGSTASH-113
|
||||
m["_#{name}"] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Allow 'INFO' 'I' or number. for 'level'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue