I am using kafka-python to get the last offset being consumed by a consumer:
def get_consumer_group_offset(group):
topic = ''
g = create_admin()
returnlist = []
counter = 0
end_offsets = g.list_consumer_group_offsets(group)
print(end_offsets)
offsets = list(end_offsets.values())
offsets_u = []
for n in offsets:
offsets_u.append(n.offset)
print("offsets_u")
print(offsets_u)
for f in end_offsets:
topic = f.topic
value = []
value.append(f.partition)
value.append(offsets_u[counter])
counter = counter + 1
returnlist.append(value)
print(returnlist)
return topic, returnlist
However I am getting the following output: (element #1 represent the partition, as you can see some partitions are being skipped for some reason)
[[1, 301], [7, 297], [10, 257], [12, 776], [14, 569], [16, 256], [20, 5], [22, 262], [28, 247]]