From 7166dce6aa111cee0c50360def82abc11b71f21c Mon Sep 17 00:00:00 2001 From: Sergio Troiano Date: Thu, 7 Mar 2024 17:07:55 +0100 Subject: [PATCH 1/2] Skip unknown protocolType in consumer groups --- kafka_exporter.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kafka_exporter.go b/kafka_exporter.go index 36021149..f296ddf2 100644 --- a/kafka_exporter.go +++ b/kafka_exporter.go @@ -569,6 +569,10 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) { return } for _, group := range describeGroups.Groups { + if group.ProtocolType != "consumer" { + klog.Warningf("Group '%v' is using a protocol type other than 'consumer'. It may not be compatible with functions relying on consumer group protocols.", group.GroupId) + continue + } offsetFetchRequest := sarama.OffsetFetchRequest{ConsumerGroup: group.GroupId, Version: 1} if e.offsetShowAll { for topic, partitions := range offset { From e4cca9c70d612fc8632b7275fe7d7005990ce4df Mon Sep 17 00:00:00 2001 From: Sergio Troiano <74413315+sciclon2@users.noreply.github.com> Date: Sat, 16 Mar 2024 07:52:47 +0100 Subject: [PATCH 2/2] Update kafka_exporter.go Addressing comments --- kafka_exporter.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/kafka_exporter.go b/kafka_exporter.go index f296ddf2..6abac6a5 100644 --- a/kafka_exporter.go +++ b/kafka_exporter.go @@ -569,10 +569,6 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) { return } for _, group := range describeGroups.Groups { - if group.ProtocolType != "consumer" { - klog.Warningf("Group '%v' is using a protocol type other than 'consumer'. It may not be compatible with functions relying on consumer group protocols.", group.GroupId) - continue - } offsetFetchRequest := sarama.OffsetFetchRequest{ConsumerGroup: group.GroupId, Version: 1} if e.offsetShowAll { for topic, partitions := range offset { @@ -585,7 +581,7 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) { assignment, err := member.GetMemberAssignment() if err != nil { klog.Errorf("Cannot get GetMemberAssignment of group member %v : %v", member, err) - return + continue } for topic, partions := range assignment.Topics { for _, partition := range partions {