Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Members in a consumer group #72

Merged
merged 1 commit into from
Nov 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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