A blank line in a json log makes logstash throw an error:
:message=>"JSON codec is expecting array or object/map", :data=>"", :level=>:error
since upgrade to logstash 2.3.4
Is this a bug or a feature?
I'd prefer if blank lines got ignored.
A blank line in a json log makes logstash throw an error:
:message=>"JSON codec is expecting array or object/map", :data=>"", :level=>:error
since upgrade to logstash 2.3.4
Is this a bug or a feature?
I'd prefer if blank lines got ignored.
I got the same error whether I used the json codec in my input config or in my filter config.
Here's a workaround. It's not pretty, but it works (for me, at least).
Don't use the json codec in the file input config.
Use an if/else clause in your filter plugin to drop blank lines. ref: http://stackoverflow.com/questions/28457936/how-can-i-drop-an-empty-line-in-logstash
filter {
if [message] =~ /^\s*$/ { drop { } }
else {
json { source => "message" }
[the rest of your config]
}
}
The result is no errors, but you will get the annoying "Parsed JSON object/hash requires a target configuration option" warnings.
Hope this helps.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.