Skip to content

Possibility to parse with ALLOW_UNESCAPED_CONTROL_CHARS (or maybe more general way to configure parser features?) #53

@Mekk

Description

@Mekk

(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:

  1. This plugin simply delegates task to code from logstash-core/lib/logstash/json.rb

  2. … which in turn simply calls JrJackson::Ruby: https://github.com/elastic/logstash/blob/main/logstash-core/lib/logstash/json.rb#L29

  3. … 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

  4. … 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions