Skip to content

[Canary] processor_labels: plugging issue of missing static labels on concatenation - #12420

Draft
cosmo0920 wants to merge 3 commits into
masterfrom
cosmo0920-canary-plugging-issue-of-missing-static-labels-on-concatenation
Draft

cosmo0920 wants to merge 3 commits into
masterfrom
cosmo0920-canary-plugging-issue-of-missing-static-labels-on-concatenation

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

This PR is depending on fluent/cmetrics#302.

Also, added runtime tests and integration tests.

The root cause of this issue is:

Confirmed: the labels processor treats cmt_cat() as a full context clone, but it does not preserve context-level static labels. The local binary reproduces your result.

The failure path is:

  1. original="value" is stored as a per-series label.
  2. The first processor’s upsert sees that first is absent from the dynamic labels and adds it to cmt->static_labels. See upsert_labels().
  3. The second processor creates an empty context and calls cmt_cat(out_cmt, metrics_context). See cb_process_metrics() line 1858.
  4. `cmt_cat()` line 1093 copies metric families, including their per-series labels, but never copies src->static_labels. Thus original survives and first disappears before the second processor applies its operations.
  5. The second processor adds second="two" to its new context.

Observed results:

Configuration Exported labels
One processor: upsert first original="value", first="one"
Two processors: upsert first, then upsert second original="value", second="two"
One processor: upsert first and insert second All three labels
Two processors: upsert first, then update original Only original="changed"

The last case establishes that this affects any subsequent labels processor, even one that only updates an unrelated label.

The focused fix would be to deep-copy the incoming static labels into the new context before applying label operations, with allocation-failure cleanup. Changing cmt_cat() globally needs more consideration: it also merges contexts, and adding source labels globally could apply them to unrelated destination metrics.

Existing coverage misses this because the upsert test configures multiple operations on a single processor.

Verification:

  • ctest --test-dir build -R processor_labels --output-on-failure — passed.
  • MEMCHECK=1 python3 /tmp/repro_labels_chain.py — reproduced the same results under Valgrind. Memory check failed in the two chained cases, reporting DNS lookup and input-coroutine leaks at shutdown; those stacks do not establish a connection to the label-copy defect.

    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:

    • Example configuration file for the change
    • Debug log output from testing the change
    • Attached Valgrind output that shows no leaks or memory corruption was found

    If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

    • Run local packaging test showing all targets (including any new ones) build.
    • Set ok-package-test label to test for all targets (requires maintainer to do).

    Documentation

    • Documentation required for this feature

    Backporting

    • Backport to latest stable release.

    Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Import fluent/cmetrics commit bf85d9ebccb6e4c4e34b8c8574281440dc28530b.

Copy static labels across contexts, deduplicate matching labels, and reject
conflicting static values or destination metric label keys before appending.
Include the upstream API contract and regression tests.

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant