A powerful command-line tool for diagnosing and troubleshooting Apache Kafka connectivity.
kshark
acts like a network sniffer for Kafka, providing a comprehensive health check of your entire client-to-broker communication path. It helps developers and SREs quickly identify issues related to DNS, TCP, TLS, SASL authentication, and Kafka protocol-level interactions.
- Layered Connectivity Checks: Systematically tests the stack from network (L3/L4) and security (L5/6) up to the Kafka protocol (L7).
- End-to-End Probes: Optionally performs a full produce-and-consume loop to a specified topic to validate data flow.
- AI-Powered Analysis (Premium): Integrates with AI providers to analyze report failures, suggest root causes, and provide actionable fixes.
- CI/CD Ready:
- Cross-Platform Builds: GitHub Actions workflow automatically compiles binaries for Linux, macOS, and Windows.
- Dockerized: Comes with a multi-stage
Dockerfile
for building a minimal, secure container image for Kubernetes or other container environments.
- Extensible Configuration: Uses a simple
.properties
file format, familiar to Java/Kafka developers, to configure all connection parameters.
- Go (version 1.23 or newer) installed.
- Docker installed and running.
- Access to a Kafka cluster.
-
Clone the Repository:
git clone https://github.com/your-username/kshark.git cd kshark
-
Configure:
- Copy the example configuration file:
cp client.properties.example client.properties
. - Edit
client.properties
with your Kafka broker and security details. - (Optional) For the AI analysis feature, copy
ai_config.json.example
toai_config.json
and add your API keys.
- Copy the example configuration file:
-
Build the Binary:
go build -o kshark ./cmd/kshark
-
Run a Health Check:
# Basic connectivity and metadata check ./kshark -props client.properties # Include a produce/consume test on a specific topic ./kshark -props client.properties -topic my-test-topic # Run the AI analysis on the results (requires license.key) ./kshark -props client.properties -topic my-test-topic --analyze
You can also build and run kshark
as a Docker container.
-
Build the Image: From the
IMPL/kshark
directory, run:docker build -t kshark:latest .
-
Run the Container: A test script is provided to simplify running the container. It mounts the necessary configuration files from your local directory.
- Ensure your
client.properties
,ai_config.json
, andlicense.key
are in theIMPL/kshark
directory. - Make the test script executable:
chmod +x test_docker.sh
- Run the test script:
./test_docker.sh
This will run the
kshark
tool inside the container and save the output reports to a newreports/
directory on your local machine. - Ensure your
/cmd/kshark
: Main application entry point./web/templates
: Contains the HTML template for AI analysis reports./.github/workflows
: GitHub Actions CI/CD pipeline for automated builds./Dockerfile
: For building the application container image.go.mod
,go.sum
: Go module dependency files.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.