-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add consumer_lag in Kafka consumergroup metricset #14822
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d9b5704
Add consumer_lag in Kafka consumergroup metricset
ChrsMark 558a39b
Fix sub and tests
ChrsMark 3f8a29e
Include consumer_lag in unit_test checks
ChrsMark 2eec175
Refactor methods to reuse struct fields
ChrsMark 5379558
Merge remote-tracking branch 'upstream/master' into add_consumer_lag
ChrsMark 85a29aa
Close client connection
ChrsMark 0f6a8ef
Store cluster client in Broker struct for reusability
ChrsMark 6500bf7
Update data.json
ChrsMark 7061004
Review fixes
ChrsMark 240c16e
Add changelog
ChrsMark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,49 @@ | ||
{ | ||
"@timestamp": "2017-10-12T08:05:34.853Z", | ||
"beat": { | ||
"hostname": "host.example.com", | ||
"name": "host.example.com" | ||
"event": { | ||
"dataset": "kafka.consumergroup", | ||
"duration": 115000, | ||
"module": "kafka" | ||
}, | ||
"kafka": { | ||
"broker": { | ||
"address": "172.18.0.2:9092", | ||
"address": "localhost:32768", | ||
"id": 0 | ||
}, | ||
"consumergroup": { | ||
"broker": { | ||
"address": "172.18.0.2:9092", | ||
"address": "localhost:32768", | ||
"id": 0 | ||
}, | ||
"client": { | ||
"host": "172.18.0.1", | ||
"id": "sarama", | ||
"member_id": "sarama-fcb5a5db-0474-4f3a-a5af-29e2f14549c5" | ||
"host": "127.0.0.1", | ||
"id": "consumer-1", | ||
"member_id": "consumer-1-a12ac7d4-00aa-45a0-8b35-0a9c6e880bf4" | ||
}, | ||
"consumer_lag": 1059, | ||
"error": { | ||
"code": 0 | ||
}, | ||
"id": "test-group", | ||
"id": "console-consumer-50413", | ||
"meta": "", | ||
"offset": -1, | ||
"partition": 0, | ||
"topic": "metricbeat-test" | ||
"topic": "test" | ||
}, | ||
"partition": { | ||
"id": 0, | ||
"topic_id": "0-metricbeat-test" | ||
"topic_id": "0-test" | ||
}, | ||
"topic": { | ||
"name": "metricbeat-test" | ||
"name": "test" | ||
} | ||
}, | ||
"metricset": { | ||
"host": "kafka:9092", | ||
"module": "kafka", | ||
"name": "consumergroup", | ||
"rtt": 115 | ||
"period": 10000 | ||
}, | ||
"service": { | ||
"address": "localhost:32768", | ||
"type": "kafka" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something to explore here.
I guess that it may happen that the partition offset here is always going to be ahead of the group offset, because we get first the group offset, and then the partition offset. Between both operations the partition offset may have changed.
Starting on version 4 of
ListOffsets
(the API method used to get partition offsets), it is possible to indicate acurrent_leader_epoch
to retrieve "old" metadata.Starting on version 5 of
OffsetFetch
(the API method used to get consumer group offsets), its response contains aleader_epoch
field.I wonder if we can use the
leader_epoch
contained in the response ofOffsetFetch
when available to query for the offset of the partition in the same epoch. This way we could have a more accurate value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the implications for the support matrix? I'm not very familiar with API version vs Kafka versioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsoriano not sure if this can be achieved with the current implementation of GetOffset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All messages in kafka protocol are versioned, each client and broker can support a different range of versions for each message. There is a message (
ApiVersionsRequest
) to query the versions supported by the broker, we could use this method to decide if we can use the methods aware of the epoch.No, we would need to forge our own request as we do to request partition offsets to the leader. Or we could contribute to Sarama the support for these versions. 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍