Skip to content

Commit

Permalink
[INTERNAL] Export number of members and assigned partitions for each …
Browse files Browse the repository at this point in the history
…topic in a consumer group ADDENDUM

Lower cardinality by not exporting group size for un-stable groups
  • Loading branch information
amuraru committed Dec 22, 2021
1 parent 4258057 commit 1b852fe
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions prometheus/collect_consumer_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ func (e *Exporter) collectConsumerGroups(ctx context.Context, ch chan<- promethe
)

// total number of members in consumer groups
ch <- prometheus.MustNewConstMetric(
e.consumerGroupMembers,
prometheus.GaugeValue,
float64(len(group.Members)),
group.Group,
)
if len(group.Members) > 0 {
ch <- prometheus.MustNewConstMetric(
e.consumerGroupMembers,
prometheus.GaugeValue,
float64(len(group.Members)),
group.Group,
)
}

// iterate all members and build two maps:
// - {topic -> number-of-consumers}
Expand Down Expand Up @@ -103,7 +105,7 @@ func (e *Exporter) collectConsumerGroups(ctx context.Context, ch chan<- promethe
}

// number of members with no assignment in a stable consumer group
if membersWithEmptyAssignment > 0 {
if membersWithEmptyAssignment > 0 && group.State == "Stable" {
ch <- prometheus.MustNewConstMetric(
e.consumerGroupMembersEmpty,
prometheus.GaugeValue,
Expand Down

0 comments on commit 1b852fe

Please sign in to comment.