Skip to content

fix(loki.process): Multiline no longer pass empty entry if start was flushed#5746

Merged
kalleep merged 2 commits into
mainfrom
kalleep/fix-multiline
Mar 11, 2026
Merged

fix(loki.process): Multiline no longer pass empty entry if start was flushed#5746
kalleep merged 2 commits into
mainfrom
kalleep/fix-multiline

Conversation

@kalleep
Copy link
Copy Markdown
Contributor

@kalleep kalleep commented Mar 10, 2026

Issue(s) fixed by this Pull Request

In #5702 some changes to stage.multiline was made to support created timestamp along with some optimizations (No longer do a deep clone). But we also made sure to always reset to a zero entry.

This is a issue when a multiline entry is flushed before completion, either by max line or max wait. Then all lines that is not considered start line will be added to an empty entry and later flushed.

To fix this we revert to the old behavior where we clone the stored entry and keep it around for other lines.

Notes to the Reviewer

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated

@kalleep kalleep added the publish-dev:linux builds and deploys an image to grafana/alloy-dev container repository label Mar 10, 2026
@kalleep kalleep force-pushed the kalleep/fix-multiline branch 3 times, most recently from e9d59cd to 831706b Compare March 10, 2026 21:36
@kalleep kalleep added publish-dev:linux builds and deploys an image to grafana/alloy-dev container repository and removed publish-dev:linux builds and deploys an image to grafana/alloy-dev container repository labels Mar 10, 2026
@kalleep kalleep changed the title chore: investigate issue fix(loki.process): stage.multiline no longer use empty entry if flushed Mar 10, 2026
@kalleep kalleep marked this pull request as ready for review March 10, 2026 21:41
@kalleep kalleep requested a review from a team as a code owner March 10, 2026 21:41
@kalleep kalleep changed the title fix(loki.process): stage.multiline no longer use empty entry if flushed fix(loki.process): Multiline no longer pass empty entry if start was flushed Mar 10, 2026
@kalleep kalleep force-pushed the kalleep/fix-multiline branch 2 times, most recently from edccb30 to 2f9265b Compare March 11, 2026 10:28
@thampiotr thampiotr requested a review from Copilot March 11, 2026 10:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes stage.multiline behavior where continuation lines could be appended to/flush as an empty entry after the start line was flushed early (max lines / max wait), by preserving the start-line entry metadata across flushes.

Changes:

  • Preserve startLineEntry across multilineState.Reset() to keep prior start-line context for subsequent non-start lines.
  • Rebuild flushed entries by cloning labels/extracted/structured metadata while preserving the original created timestamp.
  • Add a regression test covering “start line flushed before new” behavior and adjust test logger usage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/component/loki/process/stages/multiline.go Keeps start-line context after flush and constructs flushed entries with cloned metadata + preserved created timestamp.
internal/component/loki/process/stages/multiline_test.go Updates logger setup and adds a regression test for early flush behavior.

Comment thread internal/component/loki/process/stages/multiline_test.go Outdated
Comment thread internal/component/loki/process/stages/multiline_test.go Outdated
@kalleep kalleep requested a review from thampiotr March 11, 2026 11:01
kalleep and others added 2 commits March 11, 2026 13:19
Co-authored-by: Piotr <17101802+thampiotr@users.noreply.github.com>
@kalleep kalleep force-pushed the kalleep/fix-multiline branch from 1631d44 to a04d361 Compare March 11, 2026 12:19
@kalleep kalleep merged commit 7bdedf1 into main Mar 11, 2026
46 checks passed
@kalleep kalleep deleted the kalleep/fix-multiline branch March 11, 2026 13:06
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age publish-dev:linux builds and deploys an image to grafana/alloy-dev container repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants