echo "bootstrap.servers=127.0.0.1:9092" > ~/.config/kafkacat.conf
kt topic | jq -r '.name' | sort
kt topic -filter '.*queue\.tx.*' | jq -r '.name' | sort
➞ list topics and partitions along with topic offsets (oldest/newest)
kt topic -partitions -filter '.*queue\.tx.*' | jq -r '.name as $name | .partitions[] | [$name, .id, .oldest, .newest] | @tsv' | sort
➞ list topic partitions with leaders and in-sync replicas
kt topic -partitions -leaders -replicas
➞ list consumer groups, topics subscribed and offsets for each topic/partition
kt group
➞ list consumer group offsets by topic
kt group -topic foo
➞ list consumer group offsets by topic
kt group -topic us-east-1.communication.queue.tx-email-job | jq -r '.name as $name | .offsets[] | [$name, .partition, .offset, .lag] | @tsv' | sort
kt group -reset 23 -topic fav-topic -group specials -partitions 2
➞ live consume topic foo from start and exit
kafkacat -Cet foo -K, -o -1
➞ consume topic foo from start and exit
kafkacat -Cet foo
kafkacat -Ct foo
➞ consume in given format
kafkacat -Cet foo -f 'key=%k, offset=%o, headers=%h, partition=%p, payload=%s\n'
kafkacat -Ct foo -f '--START\noffset=%o, headers=%h, partition=%p\nkey=%k\npayload=%s\n'
➞ produce from stdin with key delimiter =
kafkacat -Pt foo -K=
1=first-message
2=second-message
3=third
Ctrl-D
kafkacat -Pp 0 -t foo
something
Ctrl-D
➞ produce multiple messages delimited by space from sdtin
echo 1,a 2,b 3,c | kafkacat -Pt foo -K, -D " "
kafkacat -Pt daily-flight-topic flights.json
➞ pipe from topic to another
...
➞ purge topic by deleting all partitions with it
kafka-topics --delete --zookeeper 127.0.0.1:2181 --topic us-east-1.communication.queue.tx-notification-request
$ kafka-delete-records.sh --bootstrap-server localhost:9092 --offset-json-file share/offset.json