Multiline stage duplicating and wrongly sorting log lines

To clarify: I’m currently on Grafana Agent 0.39.2, which is obviously outdated. Due to various encountered issues with newer versions of Agent and Alloy in a Docker Swarm setup (see e.g. Debian 12: v1.1.0: panic loop · Issue #868 · grafana/alloy · GitHub) which were not fixed at the time and eroded our trust in the maturity of the solution, we have not upgraded (yet).

So now I’m seeing issues with Grafana Agent’s multiline stage in flow mode, i.e. logs are duplicated, triplicated, out-of-order etc. (no pattern recognisable), incl. both the first line and stack trace lines. The regex is simply checking line starts as per below:

stage.multiline {
   firstline = "^(x|y|z).*?$"
   max_wait_time = "3s" // Defaults to 3s
   max_lines = 128 // Defaults to 128
}

As I can’t find any issues/topics related to this, I’m wondering what might be causing it and if not a config issue, if this is fixed in Alloy/is a known issue. When I disable the multiline stage, everything looks fine, no duplicate/out-of-order entries.

Hello! Thank you for your message. I am personally not aware of issues which the multiline stage which would cause this.

Would it be possible to provide us with an example log file and config file so that we can reproduce the issue please?