From c2077c3dff418b0c265d4747b39689c3eeaf926f Mon Sep 17 00:00:00 2001 From: "yalin.sahin" Date: Mon, 20 Jan 2025 15:54:28 +0300 Subject: [PATCH 1/3] Add ListOffsets flag for more control on metrics --- minion/config_topic_config.go | 4 ++++ prometheus/collect_topic_partition_offsets.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/minion/config_topic_config.go b/minion/config_topic_config.go index 426a93e..ac228d6 100644 --- a/minion/config_topic_config.go +++ b/minion/config_topic_config.go @@ -24,6 +24,9 @@ type TopicConfig struct { // take precedence over allowed topics. IgnoredTopics []string `koanf:"ignoredTopics"` + // ListOffsets can be set to false in order to not collect any offset metrics at all. + ListOffsets bool `koanf:"listOffsets"` + // InfoMetric configures how the kafka_topic_info metric is populated InfoMetric InfoMetricConfig `koanf:"infoMetric"` } @@ -66,5 +69,6 @@ func (c *TopicConfig) SetDefaults() { c.Enabled = true c.Granularity = TopicGranularityPartition c.AllowedTopics = []string{"/.*/"} + c.ListOffsets = true c.InfoMetric = InfoMetricConfig{ConfigKeys: []string{"cleanup.policy"}} } diff --git a/prometheus/collect_topic_partition_offsets.go b/prometheus/collect_topic_partition_offsets.go index 4ca6695..74c7a81 100644 --- a/prometheus/collect_topic_partition_offsets.go +++ b/prometheus/collect_topic_partition_offsets.go @@ -14,6 +14,9 @@ func (e *Exporter) collectTopicPartitionOffsets(ctx context.Context, ch chan<- p if !e.minionSvc.Cfg.Topics.Enabled { return true } + if !e.minionSvc.Cfg.Topics.ListOffsets { + return true + } isOk := true From 34ec204566df87f04e42d465ae60c5b2c7e7621e Mon Sep 17 00:00:00 2001 From: "yalin.sahin" Date: Mon, 20 Jan 2025 16:08:52 +0300 Subject: [PATCH 2/3] change documentation for topic.ListOffsets --- docs/reference-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/reference-config.yaml b/docs/reference-config.yaml index f8570b2..bdad70a 100644 --- a/docs/reference-config.yaml +++ b/docs/reference-config.yaml @@ -102,6 +102,8 @@ minion: # IgnoredTopics are regex strings of topic names that shall be ignored/skipped when exporting metrics. Ignored topics # take precedence over allowed topics. ignoredTopics: [ ] + # ListOffsets can be set to false in order to not collect any offset metrics at all. + ListOffsets: false # infoMetric is a configuration object for the kminion_kafka_topic_info metric infoMetric: # ConfigKeys are set of strings of Topic configs that you want to have exported as part of the metric From 9bc002a6acb8690dbd28f55aa55fbd118b181883 Mon Sep 17 00:00:00 2001 From: "yalin.sahin" Date: Tue, 21 Jan 2025 14:58:56 +0300 Subject: [PATCH 3/3] Dummy commit