Skip to content

Introduce config parameter limit label expansion - #261

Open
kenhys wants to merge 1 commit into
fluent:masterfrom
kenhys:limit-cardinality-oom
Open

Introduce config parameter limit label expansion#261
kenhys wants to merge 1 commit into
fluent:masterfrom
kenhys:limit-cardinality-oom

Conversation

@kenhys

@kenhys kenhys commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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.

@kenhys
kenhys force-pushed the limit-cardinality-oom branch from ed6fde4 to c8accbc Compare August 6, 2026 05:14
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
kenhys force-pushed the limit-cardinality-oom branch from c8accbc to 243d3cc Compare August 6, 2026 05:18
@kenhys
kenhys marked this pull request as ready for review August 6, 2026 05:19
@kenhys
kenhys requested a review from Watson1978 August 6, 2026 06:44

@Watson1978 Watson1978 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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.

2 participants