diff --git a/docs/reference-config.yaml b/docs/reference-config.yaml index f8570b28..bdad70a1 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 diff --git a/minion/config_topic_config.go b/minion/config_topic_config.go index 426a93ec..ac228d6a 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 4ca66956..74c7a81a 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