Getting started
Assume a broker at localhost:9092. Every connecting command accepts --brokers directly:
kafka ping --brokers localhost:9092
kafka topic create orders --brokers localhost:9092 --partitions 3 --replication-factor 1
kafka topic list --brokers localhost:9092
kafka topic describe orders --brokers localhost:9092
kafka group list --brokers localhost:9092
Typing --brokers on every call gets old fast — kafka init writes a kafka.config.ts in the
current directory, discovered automatically from then on:
kafka init
# writes ./kafka.config.ts with client.brokers = ['localhost:9092']
kafka topic list # --brokers no longer needed
kafka doctor reports which config file (if any) was discovered, where each of its values came
from, and whether the connection actually works — the first thing to reach for when a command
connects to the wrong cluster or fails to connect at all.
kafka doctor
Add --json to any command for one machine-readable document on stdout instead of a human table:
kafka topic list --json | jq '.topics[]'
Next: Configuration, Output and scripting with JSON, Command reference.