Prerequisites
- Apache Kafka cluster (2.x or later)
- Network access from the OpenSRE environment to the Kafka brokers
Setup
Option 1: Interactive CLI
Option 2: Environment variables
Add to your.env:
| Variable | Default | Description |
|---|---|---|
KAFKA_BOOTSTRAP_SERVERS | — | Required. Comma-separated broker addresses |
KAFKA_SECURITY_PROTOCOL | PLAINTEXT | Security protocol: PLAINTEXT, SSL, SASL_PLAINTEXT, SASL_SSL |
KAFKA_SASL_MECHANISM | — | SASL mechanism: PLAIN, SCRAM-SHA-256, SCRAM-SHA-512 |
KAFKA_SASL_USERNAME | — | SASL username |
KAFKA_SASL_PASSWORD | — | SASL password |
Option 3: Persistent store
Common configurations
MSK (AWS Managed Kafka) with IAM:Investigation tools
When OpenSRE investigates a Kafka-related alert, two diagnostic tools are available:- Topic health — lists topic partition metadata: leader, replicas, ISR status, and under-replicated partitions
- Consumer group lag — retrieves committed offsets vs high watermarks per partition for a specific consumer group
Verify
Troubleshooting
| Symptom | Fix |
|---|---|
| Connection timeout | Check broker hostnames, ports, and firewall rules |
| Authentication failed | Verify SASL credentials and mechanism match the broker config |
| SSL handshake error | Ensure the broker’s TLS certificate is trusted or configure a CA cert |
| Leader not available | Broker may be restarting — wait and retry |
Security best practices
- Use SASL_SSL in production — avoid
PLAINTEXToutside of local development. - Create a dedicated Kafka user with Describe permissions only — no produce or consume.
- Store credentials in
.env, not in source code.