-
-
Save vishnuatrai/186720b3a26d2c67922f9033f22c69d8 to your computer and use it in GitHub Desktop.
script to check for kafka consumer lag
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
from kazoo.client import KazooClient | |
config = { | |
'consumer_group': '<%= @consumer_group %>', | |
'topic': '<%= @topic %>' | |
} | |
def main(): | |
zk = KazooClient() | |
zk.start() | |
partitions = zk.get_children('/consumers/%(consumer_group)s/offsets/%(topic)s' % config) | |
num_partitions = int(zk.get('/brokers/topics/%(topic)s/0' % config)[0]) | |
if len(partitions) != num_partitions: | |
print "Croak! Partition fluctuation" | |
return | |
# and now go and connect to the broker and get the last offset available... | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment