Skip to content

Instantly share code, notes, and snippets.

@vishnuatrai
Forked from zsol/gist:3682934
Created December 13, 2018 08:20
Show Gist options
  • Save vishnuatrai/186720b3a26d2c67922f9033f22c69d8 to your computer and use it in GitHub Desktop.
Save vishnuatrai/186720b3a26d2c67922f9033f22c69d8 to your computer and use it in GitHub Desktop.
script to check for kafka consumer lag
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