Introduce config parameter limit label expansion - #261
Open
kenhys wants to merge 1 commit into
Open
Conversation
kenhys
force-pushed
the
limit-cardinality-oom
branch
from
August 6, 2026 05:14
ed6fde4 to
c8accbc
Compare
In the previous versions, there is no mechanism to limit label expansion. That causes a possibility of cardinality OOM DoS. To mitigate such situation, introduced the following parameters: * max_label_value_length: The maximum length of a label value. * max_series_per_metric: The maximum number of label sets a metric can hold. The above parameter is configurable for filter_prometheus and out_prometheus. For example, if about 8 million records are loaded without cardinality limitation, RSS increased from 64MB to 582MB. It might cause OOM DoS. In contrast to that case with cardinality limitation, RSS increased from 64MB to 84 MB in similar case. Then warning message is logged like this: 2026-08-06 14:06:04 +0900 [warn]: prometheus: dropped a label set because the metric reached max_series_per_metric. name="access_requests_total" max_series_per_metric=10000 Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
kenhys
force-pushed
the
limit-cardinality-oom
branch
from
August 6, 2026 05:18
c8accbc to
243d3cc
Compare
kenhys
marked this pull request as ready for review
August 6, 2026 05:19
Watson1978
requested changes
Aug 6, 2026
Contributor
There was a problem hiding this comment.
Seems that once a record has raised an exception, valid records sent afterwards no longer show up in the metric.
Please try attached file to reproduce.
repro-261.tar.gz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the previous versions, there is no mechanism to limit label expansion. That causes a possibility of cardinality OOM DoS.
To mitigate such situation, introduced the following parameters:
The above parameter is configurable for filter_prometheus and out_prometheus.