Skip to content

Commit

Permalink
Handle Azure Eventhubs returns list duplicated servers
Browse files Browse the repository at this point in the history
  • Loading branch information
Minh Nguyen authored and keyz182 committed Aug 2, 2024
1 parent 8973a8c commit 219c6f8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,23 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) {

klog.V(DEBUG).Info("Fetching consumer group metrics")
if len(e.client.Brokers()) > 0 {
uniqueBrokerAddresses := make(map[string]bool)
var servers []string
for _, broker := range e.client.Brokers() {
wg.Add(1)
go getConsumerGroupMetrics(broker)
normalizedAddress := strings.ToLower(broker.Addr())
if !uniqueBrokerAddresses[normalizedAddress] {
uniqueBrokerAddresses[normalizedAddress] = true
servers = append(servers, broker.Addr())
}
}
klog.Info(servers)
for _, broker := range e.client.Brokers() {
for _, server := range servers {
if server == broker.Addr() {
wg.Add(1)
go getConsumerGroupMetrics(broker)
}
}
}
wg.Wait()
} else {
Expand Down

0 comments on commit 219c6f8

Please sign in to comment.