Skip to content

Commit

Permalink
Merge pull request #72 from chemasan/master
Browse files Browse the repository at this point in the history
Members in a consumer group
  • Loading branch information
danielqsj authored Nov 12, 2018
2 parents 8488376 + 1c176ef commit 5fb725f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var (
consumergroupLag *prometheus.Desc
consumergroupLagSum *prometheus.Desc
consumergroupLagZookeeper *prometheus.Desc
consumergroupMembers *prometheus.Desc
)

// Exporter collects Kafka stats from the given server and exports them using
Expand Down Expand Up @@ -364,6 +365,9 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
offsetFetchRequest.AddPartition(topic, partition)
}
}
ch <- prometheus.MustNewConstMetric(
consumergroupMembers, prometheus.GaugeValue, float64(len(group.Members)), group.GroupId,
)
if offsetFetchResponse, err := broker.FetchOffset(&offsetFetchRequest); err != nil {
plog.Errorf("Cannot get offset of group %s: %v", group.GroupId, err)
} else {
Expand Down Expand Up @@ -564,6 +568,12 @@ func main() {
[]string{"consumergroup", "topic"}, labels,
)

consumergroupMembers = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "consumergroup", "members"),
"Amount of members in a consumer group",
[]string{"consumergroup"}, labels,
)

if *logSarama {
sarama.Logger = log.New(os.Stdout, "[sarama] ", log.LstdFlags)
}
Expand Down

0 comments on commit 5fb725f

Please sign in to comment.