Skip to content

in_prometheus_remote_write: limit protobuf decode allocations per request - #12911

Draft
cosmo0920 wants to merge 13 commits into
masterfrom
cosmo0920-mitigate-unbudgeted-decoding-for-out_promehteus-remote-write
Draft

cosmo0920 wants to merge 13 commits into
masterfrom
cosmo0920-mitigate-unbudgeted-decoding-for-out_promehteus-remote-write

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

It records the three upstream CMetrics commits 69b2085, ae56f52, and 3888610. All 13 Fluent Bit commits retain DCO sign-offs and passed commit-prefix lint. The tip 8b7424ef5 has the same file tree as the tested and benchmarked build.

What changed

Fluent Bit can now accept a Prometheus remote write request larger than one decode batch. CMetrics splits it at complete time-series boundaries and resolves metadata even when it appears after the series. The receiver stages split batches in a temporary file and admits the entire request as one queue event. If a later series is malformed or too large, or the queue is full, earlier batches from that request are discarded.

max_decode_allocation_size sets the per-batch budget. max_request_decode_allocation_size bounds cumulative decoding across batches, and http_server.max_decoded_body_size limits the decoded HTTP body. [Configuration guide](/home/cosmo/Documents/GitHub/fluent-bit-dev/plugins/in_prometheus_remote_write/README.md)

Measured peak RSS

Each run sent the same 2,348,096-byte decoded node-exporter payload to a fresh Linux receiver. Values are median process peak RSS across three runs per cell. The output drained the expected batch count in all 24 runs.

Batch budget Batches per request Raw peak RSS Gzip peak RSS
256K 135 30.6 MiB 27.5 MiB
1M 35 30.8 MiB 29.0 MiB
4M 9 34.2 MiB 32.9 MiB
64M 1 67.6 MiB 63.2 MiB

For this payload, 1M reduced peak RSS by about 54% for both encodings compared with 64M. Reducing the budget further to 256K increased the batch count from 35 to 135 and saved another 0.2 MiB for raw input and 1.5 MiB for gzip. Split requests also use temporary-file space.

Verification

All 25 CMetrics tests and 5 focused Fluent Bit internal tests passed. All 19 receiver integration cases passed normally in 122.09 s and under strict Linux Valgrind in 161.88 s. The live tests verified that accepted raw, gzip, and Snappy requests delivered each sample once and that rejected requests delivered no staged prefix.

tests/integration/.venv/bin/python tests/integration/run_tests.py scenarios/in_prometheus_remote_write
tests/integration/.venv/bin/python tests/integration/run_tests.py --valgrind --valgrind-strict scenarios/in_prometheus_remote_write

This PR is depending on fluent/cmetrics#320.


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 Dec 3, 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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Import CMetrics commits 69b2085, ae56f52 and 3888610. Bound protobuf
and model allocations and decode complete time series in batches.

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant