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 May 5, 2023
1 parent 06433c7 commit f387a41
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 @@ -108,7 +110,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 f387a41

Please sign in to comment.