Monitoring Kafka Metrics with ClickStack
This guide shows you how to monitor Apache Kafka performance metrics with ClickStack by using the OpenTelemetry JMX Metric Gatherer. You'll learn how to:
- Enable JMX on Kafka brokers and configure the JMX Metric Gatherer
- Send Kafka metrics to ClickStack via OTLP
- Use a pre-built dashboard to visualize Kafka performance (broker throughput, consumer lag, partition health, request latency)
A demo dataset with sample metrics is available if you want to test the integration before configuring your production Kafka cluster.
Time required: 10-15 minutes
Integration with existing Kafka
This section covers configuring your existing Kafka installation to send metrics to ClickStack using the OpenTelemetry JMX Metric Gatherer.
If you would like to test the Kafka Metrics integration before configuring your own existing setup, you can test with our preconfigured demo dataset in the following section.
Prerequisites
- ClickStack instance running with OTLP endpoint accessible (port 4317)
- Existing Kafka installation (version 2.0 or newer)
- JMX port exposed on Kafka brokers (default port 9999)
- Java Runtime Environment (JRE) 8 or higher installed on the Kafka broker host
- Network access from Kafka broker to ClickStack OTLP endpoint
Verify Kafka JMX is enabled
Kafka exposes metrics via JMX (Java Management Extensions). Verify JMX is enabled on your Kafka brokers.
Add these settings to your Kafka broker startup configuration:
For Docker deployments:
Verify JMX is accessible:
Download the JMX Metric Gatherer
Download the OpenTelemetry JMX Metric Gatherer JAR on the Kafka broker host:
Run the JMX Metric Gatherer
Start the JMX Metric Gatherer to collect metrics from Kafka and send them to ClickStack:
Replace <clickstack-host> with your ClickStack hostname or IP address (use localhost if ClickStack is on the same host).
For JMX authentication:
For multiple Kafka brokers, run a separate JMX Metric Gatherer process on each broker with unique broker IDs:
To run as a background service, use nohup or create a systemd service:
Key metrics collected:
Broker metrics:
kafka.broker.message_in_rate- Messages received per secondkafka.broker.byte_in_rate- Bytes received per secondkafka.broker.byte_out_rate- Bytes sent per second
Partition metrics:
kafka.partition.count- Total number of partitionskafka.partition.under_replicated- Under-replicated partitions (data safety concern)kafka.partition.offline- Offline partitions (availability concern)
Request metrics:
kafka.request.produce.time.avg- Average produce request latencykafka.request.fetch_consumer.time.avg- Average consumer fetch latency
Consumer lag:
kafka.consumer.lag- Consumer group lag by topic and partition
Verify metrics in HyperDX
Once configured, log into HyperDX and verify metrics are flowing:
- Navigate to the Chart Explorer
- Search for metrics starting with
kafka.(e.g.,kafka.broker.message_in_rate,kafka.partition.count) - You should see metric data points appearing at 10-second intervals
Demo dataset
For users who want to test the Kafka Metrics integration before configuring their production systems, we provide a pre-generated dataset with realistic Kafka metrics patterns.
Download the sample metrics dataset
Download the pre-generated metrics files (29 hours of Kafka metrics with realistic patterns):
The dataset includes realistic patterns for a single-broker e-commerce Kafka cluster:
- 06:00-08:00: Morning surge - Sharp traffic ramp from overnight baseline
- 10:00-10:15: Flash sale - Dramatic spike to 3.5x normal traffic
- 11:30: Deployment event - 12x consumer lag spike with under-replicated partitions
- 14:00-15:30: Peak shopping - Sustained high traffic at 2.8x baseline
- 17:00-17:30: After-work surge - Secondary traffic peak
- 18:45: Consumer rebalance - 6x lag spike during rebalancing
- 20:00-22:00: Evening drop - Steep decline to overnight levels
Start ClickStack
Start a ClickStack instance:
Wait approximately 30 seconds for ClickStack to fully start.
Verify metrics in HyperDX
Once loaded, the quickest way to see your metrics is through the pre-built dashboard.
Proceed to the Dashboards and visualization section to import the dashboard and view all Kafka metrics at once.
The demo dataset time range is 2025-11-05 16:00:00 to 2025-11-06 16:00:00. Make sure your time range in HyperDX matches this window.
Dashboards and visualization
To help you get started monitoring Kafka with ClickStack, we provide essential visualizations for Kafka metrics.
Import the pre-built dashboard
- Open HyperDX and navigate to the Dashboards section
- Click Import Dashboard in the upper right corner under the ellipses
- Upload the
kafka-metrics-dashboard.jsonfile and click Finish Import
View the dashboard
The dashboard will be created with all visualizations pre-configured:
For the demo dataset, ensure the time range is set to 2025-11-05 16:00:00 to 2025-11-06 16:00:00.
Troubleshooting
JMX Metric Gatherer not starting
Verify Java is installed and in your PATH:
Check that the JAR file was downloaded successfully:
No metrics appearing in HyperDX
Verify the JMX Metric Gatherer is running:
Verify Kafka's JMX port is accessible:
Verify ClickStack's OTLP endpoint is reachable:
Check if metrics are in ClickHouse:
JMX authentication errors
If you see authentication errors when starting the JMX Metric Gatherer:
Add authentication parameters to the java command:
Network connectivity issues
If the JMX Metric Gatherer can't reach Kafka JMX or ClickStack OTLP:
Missing specific metrics
If certain Kafka metrics are not appearing:
- Verify the metric exists in Kafka's JMX endpoint using a JMX browser tool like JConsole
- Check that
target_system: kafkais set correctly - Some metrics may only appear under specific conditions (e.g., consumer lag only appears when consumers are active)
- Review the OpenTelemetry JMX Metric Gatherer documentation for the complete list of Kafka metrics
Next steps
- Set up alerts for critical metrics (under-replicated partitions, consumer lag thresholds, high request latency)
- Monitor multiple Kafka brokers by running separate JMX Metric Gatherer processes with different broker IDs
- Correlate Kafka metrics with application traces to understand end-to-end request performance