multiline: add built-in json parser for JSON multiline objects - #12264
multiline: add built-in json parser for JSON multiline objects#12264lecaros wants to merge 5 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe change adds a built-in JSON multiline parser, exposes its factory, documents the ChangesJSON multiline parser support
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Config
participant BuiltinFactory
participant JSONParser
participant JSONTest
Config->>BuiltinFactory: selects json parser
BuiltinFactory->>JSONParser: creates parser
JSONTest->>JSONParser: appends fixtures and flushes pending data
JSONParser-->>JSONTest: emits expected records
Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cc6f17f9da
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/internal/multiline.c`:
- Around line 367-400: Add invalid-boundary fixtures to json_input and
json_output covering an opening brace followed by an unindented line and a
closing-brace line with trailing content. Assert that each malformed
continuation does not merge into the active JSON group, and include both the
resulting valid records and invalid payload outcomes, including the relevant
boundary-size cases.
- Around line 1229-1230: Restore the flb_time_get(&tm) call immediately before
flb_ml_append_text in the affected test flow, ensuring tm is initialized before
being passed to the append operation and removing the invalid `-.` artifact.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5fe3bb36-a478-4ea5-9d3a-cc31c23d07ad
📒 Files selected for processing (6)
include/fluent-bit/multiline/flb_ml_parser.hplugins/filter_multiline/ml.cplugins/in_tail/tail.csrc/multiline/CMakeLists.txtsrc/multiline/flb_ml_parser.ctests/internal/multiline.c
cc6f17f to
61b3d44
Compare
61b3d44 to
c95af44
Compare
Signed-off-by: lecaros <lecaros@chronosphere.io>
Signed-off-by: lecaros <lecaros@chronosphere.io>
Add flb_ml_parser_json with regex grouping from an opening brace through indented continuation lines. Do not attach a per-line JSON parser; parse the assembled log field with filter_parser instead. Signed-off-by: lecaros <lecaros@chronosphere.io>
Signed-off-by: lecaros <lecaros@chronosphere.io>
c95af44 to
a94e2c8
Compare
Cover unindented continuation lines and closing braces with trailing content so malformed lines are not merged into an active JSON group. Signed-off-by: lecaros <lecaros@chronosphere.io>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 171ea2102a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Add built-in multiline parser
jsonfor tail inputs that read JSON objects split across lines.The parser groups lines only (regex start
^\{.*, continuation onwhitespace-indented lines or a lone
}). It does not embed a JSON parser;per-line JSON parsing fails on partial lines such as
{or"id": 102,.Expected usage:
multiline.parser: jsonon tail, thenfilter_parserwithkey_name: logandparser: json.parser: jsonon tail; no multilineparser.
Addresses #2418, #8232
Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
config
oneline.json
{"id":1,"time":"2026-08-11T10:00:00.000","level":"info","msg":"oneline record one"} {"id":2,"time":"2026-08-11T10:00:01.000","level":"warn","msg":"oneline record two"} {"id":3,"time":"2026-08-11T10:00:02.000","level":"error","msg":"oneline record three"}mixed.json
{"id":101,"time":"2026-08-11T11:00:00.000","level":"info","msg":"single-line record A"} { "id": 102, "time": "2026-08-11T11:00:01.000", "level": "warn", "msg": "multiline record B", "details": { "user": "alice", "action": "login" } } {"id":103,"time":"2026-08-11T11:00:02.000","level":"info","msg":"single-line record C"} {"id": 104, "time": "2026-08-11T11:00:03.000", "level": "error", "msg": "multiline record D", "stack": [ "frame1", "frame2" ] } {"id":105,"time":"2026-08-11T11:00:04.000","level":"info","msg":"single-line record E"}debug output
Documentation
Backporting
Valgrind output
output
Summary by CodeRabbit
New Features
jsonto the supported multiline parser configuration options.Bug Fixes
Tests