From 84b31762236e6c9b58531ebd71a3af3fc79b5e86 Mon Sep 17 00:00:00 2001 From: Sergio Troiano Date: Thu, 14 Mar 2024 10:50:53 +0100 Subject: [PATCH] Fixed scenario where consumers may not have assignments in Consumer Groups --- kafka_exporter.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kafka_exporter.go b/kafka_exporter.go index 36021149..9a70ae83 100644 --- a/kafka_exporter.go +++ b/kafka_exporter.go @@ -578,6 +578,10 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) { } } else { for _, member := range group.Members { + if len(member.MemberAssignment) == 0 { + klog.Warningf("MemberAssignment is empty for group member: %v in group: %v", member.MemberId, group.GroupId) + continue + } assignment, err := member.GetMemberAssignment() if err != nil { klog.Errorf("Cannot get GetMemberAssignment of group member %v : %v", member, err)