Skip to content

feat(config): add global label length limits#1

Open
rabellamy wants to merge 1 commit into
mainfrom
16525-Set-label_value_length_limit
Open

feat(config): add global label length limits#1
rabellamy wants to merge 1 commit into
mainfrom
16525-Set-label_value_length_limit

Conversation

@rabellamy

Copy link
Copy Markdown
Owner

This PR introduces two new global configuration parameters, label_name_length_limit and label_value_length_limit, which provide a safety ceiling on the maximum allowable size for label names and values.
By setting these global limits, Prometheus dynamically enforces restrictions at multiple system boundaries to protect against Out-Of-Memory (OOM) crashes and excessive resource consumption caused by astronomically large labels:

  • Scrape & Parsers (model/textparse, scrape): Drops incoming scrape payloads and series that expose metrics with labels exceeding the threshold.
  • Remote Write (storage/remote): Drops violating series and returns an HTTP 400 Bad Request, preventing misconfigured remote senders from overwhelming the ingestion path.
  • PromQL (promql): Returns an evaluation error during query execution if functions like label_replace or label_join attempt to mutate and generate labels that violate the limits.
  • Documentation: Updated docs/configuration/configuration.md to detail usage.
  • Testing: Added unit test coverage for the limits in promql/label_limits_test.go and storage/remote/label_limits_test.go and verified the full test suite passes.

Which issue(s) does the PR fix:

Fixes prometheus#16525

Release notes for end users (ALL commits must be considered).

Reviewers should verify clarity and quality.

[FEATURE] config: Add `label_name_length_limit` and `label_value_length_limit` to GlobalConfig to safely limit label sizes.

@rabellamy rabellamy force-pushed the 16525-Set-label_value_length_limit branch from 598759c to 53d4a2d Compare June 24, 2026 13:53
This commit introduces two new global configuration parameters, `label_name_length_limit` and `label_value_length_limit`, which provide a safety ceiling on the maximum allowable size for label names and values.
By setting these global limits, Prometheus dynamically enforces restrictions at multiple system boundaries to protect against Out-Of-Memory (OOM) crashes and excessive resource consumption caused by astronomically large labels:
- **Scrape & Parsers** (`model/textparse`, `scrape`): Drops incoming scrape payloads and series that expose metrics with labels exceeding the threshold.
- **Remote Write** (`storage/remote`): Drops violating series and returns an HTTP 400 Bad Request, preventing misconfigured remote senders from overwhelming the ingestion path.
- **PromQL** (`promql`): Returns an evaluation error during query execution if functions like `label_replace` or `label_join` attempt to mutate and generate labels that violate the limits.

Fixes prometheus#16525
@rabellamy rabellamy force-pushed the 16525-Set-label_value_length_limit branch from 53d4a2d to 40f959b Compare June 24, 2026 14:09
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.

Set and check (and document) a global label_value_length_limit

1 participant