-
Notifications
You must be signed in to change notification settings - Fork 45
Description
(this feature requires changes in some underlying libraries to be implemented, but I decided to report it to provide purpose, going to report separate request to jrjackson)
TLDR
Jackson parser has „allow unescaped newlines” feature. Would be great if json filter allowed to set some option to use it.
Context
I happen to use logs containing json text with unquoted newlines. It is done on purpose as logs are also ready by humans and
"something": "Blah blah
blah blah
blah blah"
is by far more human-reader friendly than
"something": "Blah blah\nblah blah\nblah blah"
(esp. when the text is longer).
Unfortunately such json can't be parsed using json filter, as any attempts end up with Illegal unquoted character CTRL-CHAR, code 10
.
Possibilities
I did some digging and it looks like underlying parser has option which would allow one to parse such json.
In detail:
-
This plugin simply delegates task to code from
logstash-core/lib/logstash/json.rb
-
… which in turn simply calls JrJackson::Ruby: https://github.com/elastic/logstash/blob/main/logstash-core/lib/logstash/json.rb#L29
-
… which in turn wraps java code and critical place is more or less here: https://github.com/guyboertje/jrjackson/blob/master/src/main/java/com/jrjackson/JrJacksonRuby.java#L75
-
… and if I understand correctly „allow unescaped control chars” could be configured similarly to FAIL_ON_SYMBOL_HASH_OVERFLOW (although it is somewhat version dependent whether it is JsonParser.Feature or JSonReadFeature). . I ggled some more detailed suggestions in How to use JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS FasterXML/jackson-core#586
So, in general possible implementation would require change in jrjackson ruby wrapper (to provide such option) and then could be consumed by providing such option in logstash json parser and this plugin.