Skip to content

Commit

Permalink
Members in a consumer group
Browse files Browse the repository at this point in the history
  • Loading branch information
chemasan committed Nov 9, 2018
1 parent 8488376 commit 1c176ef
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 1c176ef

Please sign in to comment.