Skip to content

Commit

Permalink
Merge pull request #220 from iamgd67/consumer_offset_request_fetch_on…
Browse files Browse the repository at this point in the history
…ly_assigned_paritions

use group assignment to fetch consumer offset instead of fetch all partitions
  • Loading branch information
danielqsj authored May 18, 2021
2 parents 0e014a2 + fb84b44 commit 9514777
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,16 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
}
for _, group := range describeGroups.Groups {
offsetFetchRequest := sarama.OffsetFetchRequest{ConsumerGroup: group.GroupId, Version: 1}
for topic, partitions := range offset {
for partition := range partitions {
offsetFetchRequest.AddPartition(topic, partition)
for _, member := range group.Members {
assignment, err := member.GetMemberAssignment()
if err != nil {
plog.Errorf("Cannot get GetMemberAssignment of group member %v : %v", member, err)
return
}
for topic, partions := range assignment.Topics {
for _, partition := range partions {
offsetFetchRequest.AddPartition(topic, partition)
}
}
}
ch <- prometheus.MustNewConstMetric(
Expand Down

0 comments on commit 9514777

Please sign in to comment.