| name | kafka |
| version | 1.0.0 |
| description | Kafka topic management, consumer group monitoring, message production/consumption, and cluster health diagnostics. Use when working with Kafka brokers, topics, consumer lag, or debugging pipeline issues. |
Kafka Operations
When to Use
- Managing Kafka topics (create, describe, delete, list)
- Monitoring consumer group lag
- Producing or consuming messages for testing
- Diagnosing broker connectivity issues
- Checking partition offsets and health
- Debugging logstash pipelines that read from or write to Kafka
Common Commands
Cluster Status
kafka-broker-api-versions --bootstrap-server localhost:9092
kafka-topics --bootstrap-server localhost:9092 --list
kafka-topics --bootstrap-server localhost:9092 --describe --topic <topic>
Topic Management
kafka-topics --bootstrap-server localhost:9092 --create --topic <name> --partitions 3 --replication-factor 1
kafka-topics --bootstrap-server localhost:9092 --delete --topic <name>
kafka-topics --bootstrap-server localhost:9092 --alter --topic <name> --partitions <count>
Consumer Groups
kafka-consumer-groups --bootstrap-server localhost:9092 --list
kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group <group>
kafka-consumer-groups --bootstrap-server localhost:9092 --group <group> --topic <topic> --reset-offsets --to-earliest --execute
Produce and Consume
echo "key:value" | kafka-console-producer --bootstrap-server localhost:9092 --topic <topic> --property "parse.key=true" --property "key.separator=:"
kafka-console-consumer --bootstrap-server localhost:9092 --topic <topic> --from-beginning --max-messages 10
kafka-console-consumer --bootstrap-server localhost:9092 --topic <topic> --from-beginning --property print.key=true --property key.separator="|"
Offset Inspection
kafka-run-class kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic <topic>
Deer Sandbox Integration
When debugging Kafka-dependent services in a deer sandbox with kafka_stub=true:
- Redpanda runs at
localhost:9092 inside the sandbox
- Use
rpk topic list --brokers localhost:9092 for topic management
- Use
rpk topic produce <topic> --brokers localhost:9092 to send test messages
- Use
rpk topic consume <topic> --brokers localhost:9092 to read messages
- Use
rpk group list --brokers localhost:9092 for consumer groups
Diagnostic Patterns
High Consumer Lag
- Check lag:
kafka-consumer-groups --describe --group <group>
- Check consumer is running:
systemctl status <consumer-service>
- Check topic end offsets:
GetOffsetShell --topic <topic>
- Common causes: slow consumer, network latency, too few partitions, consumer crashes
Broker Connectivity Issues
- Verify broker is listening:
ss -tlnp | grep 9092
- Check advertised.listeners in server.properties
- Test connectivity:
kafka-broker-api-versions --bootstrap-server <host>:9092
- Check logs:
journalctl -u kafka --no-pager -n 100
Logstash Kafka Input Issues
- Verify topic exists and has data
- Check consumer group lag
- Verify bootstrap_servers config in logstash pipeline
- Check logstash logs for connection errors:
journalctl -u logstash --no-pager -n 100
- In sandbox: replace bootstrap address with
localhost:9092