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

[rhythm] Implement group-consuming in the metrics-generator #4593

Merged
merged 4 commits into from
Jan 28, 2025

Conversation

mapno
Copy link
Member

@mapno mapno commented Jan 22, 2025

What this PR does:

This PR introduces group consuming to the generators, instead of the previously used direct consuming. Group consuming delegates partitions assignment to Kafka, which greatly simplifies operations for the generators.

It uses a custom balancer that combines Kafka's cooperative sticky balancing with partition ring awareness. This implementation is forked from Loki.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

// This is so the cycle started exactly at the commit offset, and not at what was (potentially over-) consumed previously.
// In the end, we remove the partition from the client (refer to the defer below) to guarantee the client always consumes
// from one partition at a time. I.e. when this partition is consumed, we start consuming the next one.
g.kafkaClient.AddConsumePartitions(map[string]map[int32]kgo.Offset{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help clarify for my understanding - since this client update is removed, how does PollFetches know which partitions are assigned? Is that now handled by the server (broker, etc)?

Copy link
Member Author

@mapno mapno Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, when joining a group (ie. kgo.ConsumerGroup(kafkaCfg.ConsumerGroup)) Kafka handles partitions assignment. The client will talk to the broker which will share the partition balance for it. In each pull, the client will receive fetches for the partitions that have been assigned to it.

@mapno mapno merged commit 53eaf16 into grafana:main Jan 28, 2025
14 checks passed
@mapno mapno deleted the generator-group-consuming branch January 28, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants