fluent / fluent-bit

Fast and Lightweight Logs and Metrics processor for Linux, BSD, OSX and Windows
https://fluentbit.io
Apache License 2.0
5.69k stars 1.55k forks source link

Adding "\n" while using multiline.parser with Tail #8914

Open duj4 opened 3 months ago

duj4 commented 3 months ago

Bug Report

Describe the bug “\n” will be added when using multiline.parser.

To Reproduce The simplest one is the official one: before:

single line...
Dec 14 06:41:08 Exception in thread "main" java.lang.RuntimeException: Something has gone wrong, aborting!
    at com.myproject.module.MyProject.badMethod(MyProject.java:22)
    at com.myproject.module.MyProject.oneMoreMethod(MyProject.java:18)
    at com.myproject.module.MyProject.anotherMethod(MyProject.java:14)
    at com.myproject.module.MyProject.someMethod(MyProject.java:10)
    at com.myproject.module.MyProject.main(MyProject.java:6)
another line...

after:

[0] tail.0: [0.000000000, {"log"=>"single line...
"}]
[1] tail.0: [1626634867.472226330, {"log"=>"Dec 14 06:41:08 Exception in thread "main" java.lang.RuntimeException: Something has gone wrong, aborting!
    at com.myproject.module.MyProject.badMethod(MyProject.java:22)
    at com.myproject.module.MyProject.oneMoreMethod(MyProject.java:18)
    at com.myproject.module.MyProject.anotherMethod(MyProject.java:14)
    at com.myproject.module.MyProject.someMethod(MyProject.java:10)
    at com.myproject.module.MyProject.main(MyProject.java:6)
"}]
[2] tail.0: [1626634867.472226330, {"log"=>"another line...
"}]

Expected behavior Both single line and multi-line logs should be as still, no "\n" is added:

[0] tail.0: [0.000000000, {"log"=>"single line..."}]
[1] tail.0: [1626634867.472226330, {"log"=>"Dec 14 06:41:08 Exception in thread "main" java.lang.RuntimeException: Something has gone wrong, aborting!
    at com.myproject.module.MyProject.badMethod(MyProject.java:22)
    at com.myproject.module.MyProject.oneMoreMethod(MyProject.java:18)
    at com.myproject.module.MyProject.anotherMethod(MyProject.java:14)
    at com.myproject.module.MyProject.someMethod(MyProject.java:10)
    at com.myproject.module.MyProject.main(MyProject.java:6)"}]
[2] tail.0: [1626634867.472226330, {"log"=>"another line..."}]

image

Screenshots Another example in my own case:

multiline-parser: image

parser: image

before: image

after: image

Your Environment

duj4 commented 3 months ago

Same issue had been opened in https://github.com/fluent/fluent-bit/issues/4227 but without any further update.

duj4 commented 3 months ago

Thanks @patrick-stephens 's suggestion, Lua can remove the last "\n" but it will twist the record order: image

Any further suggestion would be appreciated.

duj4 commented 3 months ago

Another workaround is add a "\n" to the end of parser to match the newly added newline, so the new parser will be: image

However, it would be better to fix the "adding newline" issue natively. @lecaros

lecaros commented 3 days ago

hi there. What's the impact of this issue other than the visualization in stdout?

duj4 commented 15 hours ago

hi @lecaros , thanks for the reply.

The impact I could see for now is the visualization in either output or Grafana, but that's not a big deal, you may close this one for now.