From 8dab9d1bc99f6c0050d4aafe1575f716fed2e8c5 Mon Sep 17 00:00:00 2001 From: Brandon Allard Date: Mon, 16 Sep 2024 22:42:57 -0400 Subject: [PATCH] kafka: remove shard aggregation on consumer group metrics Currently we only aggregate on the `shard` label in the consumer group metrics. This aggregation doesn't result in a reduced number of metric series. It does, however, cause seastar to use the `metric_aggregate_by_labels` class to aggregate the metrics. This class uses a contiguous map type that isn't easily replaced and in cases where there are many consumer groups, kafka topics, and partitions there is enough unique label sets to cause an oversized allocation in the continguous map. By removing the `shard` label from aggregation though we avoid the code path where `metric_aggregate_by_labels` is used and hence avoid the oversized allocation. (cherry picked from commit ca8cd1ef50521cbf7ee39a5e517594b9f5cb6439) --- src/v/kafka/group_probe.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/v/kafka/group_probe.h b/src/v/kafka/group_probe.h index 0ba5da9272f7c..606c698d7fe48 100644 --- a/src/v/kafka/group_probe.h +++ b/src/v/kafka/group_probe.h @@ -78,11 +78,10 @@ class group_offset_probe { _public_metrics.add_group( prometheus_sanitize::metrics_name("kafka:consumer:group"), {sm::make_gauge( - "committed_offset", - [this] { return _offset; }, - sm::description("Consumer group committed offset"), - labels) - .aggregate({sm::shard_label})}); + "committed_offset", + [this] { return _offset; }, + sm::description("Consumer group committed offset"), + labels)}); } private: @@ -130,15 +129,13 @@ class group_probe { "consumers", [this] { return _members.size(); }, sm::description("Number of consumers in a group"), - labels) - .aggregate({sm::shard_label}), + labels), sm::make_gauge( "topics", [this] { return _offsets.size(); }, sm::description("Number of topics in a group"), - labels) - .aggregate({sm::shard_label})}); + labels)}); } private: