Integration with Apache Kafka
This guide explains how to monitor Apache Kafka using the OpenTelemetry Collector Contrib (otelcol-contrib) and export metrics to OpenObserve for visualization.
Overview
Monitoring Kafka is essential for ensuring performance, reliability, and data integrity.With OpenTelemetry and OpenObserve, you gain real-time visibility into Kafka clusters, topics, consumers, and producers.
Steps to Integrate
Prerequisites
- OpenObserve account (Cloud or Self-Hosted)
 - Kafka running
 
Step 1: Create Test Kafka Topics (Optional)
- 
Create test topics to simulate workloads:
bin/kafka-topics.sh --create --topic quickstart-events-1 --partitions 3 --bootstrap-server localhost:9092 bin/kafka-topics.sh --create --topic quickstart-events-2 --partitions 10 --bootstrap-server localhost:9092 bin/kafka-topics.sh --create --topic openobserve --partitions 2 --bootstrap-server localhost:9092 - 
List topics to confirm:
 
Step 2: Install OpenTelemetry Collector Contrib
Download and install the latest otelcol-contrib.
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.116.1/otelcol-contrib_0.116.1_linux_amd64.deb
sudo dpkg -i otelcol-contrib_0.116.1_linux_amd64.deb
Note: Replace version numbers in download links if a newer release is available. Always check the GitHub Releases page.
Step 3: Get OpenObserve URL and Access Key
- In OpenObserve: go to Data Sources → Custom → Metrics → Otel Collector
 - Copy the ingestion URL and Access Key

 
Step 4: Configure OpenTelemetry Collector
- Edit the configuration file:
 - 
Update config for Kafka metrics:
receivers: kafkametrics: brokers: localhost:9092 protocol_version: 2.0.0 scrapers: - brokers - topics - consumers exporters: otlphttp/openobserve: endpoint: OPENOBSERVE_ENDPOINT headers: Authorization: OPENOBSERVE_TOKEN stream-name: OPENOBSERVE_STREAM service: pipelines: metrics: receivers: [kafkametrics] exporters: [otlphttp/openobserve] 
Replace the following with your OpenObserve details:
OPENOBSERVE_ENDPOINT→ API endpoint (e.g.,https://api.openobserve.ai)OPENOBSERVE_TOKEN→ API tokenOPENOBSERVE_STREAM→ Stream name
Step 5: Start OpenTelemetry Collector
- Start and check status:
 - Check logs:
 
Step 6: Visualize in OpenObserve
- Go to Streams → select metrics. Expand on any metric stream to see the events.

 
Tip
You can use prebuilt dashboards to quickly get started with Kafka monitoring. Browse and import dashboards from: OpenObserve Community Dashboards
Troubleshooting
- Collector Fails to Start: 
failed to build pipelines: unknown receiver kafkametrics- Cause: Using an older 
otelcol-contribversion that doesn’t support thekafkametricsreceiver. - Fix: Upgrade to at least 
v0.116.0or newer from GitHub Releases. 
 - Cause: Using an older 
 - No Metrics Visible in OpenObserve
- Double-check values in your 
config.yamlagainst your OpenObserve → Data Sources → Custom → Metrics → Otel Collector page. 
 - Double-check values in your 
 - Kafka Connection Errors: 
dial tcp 127.0.0.1:9092: connect: connection refused- Cause: Kafka broker not running or wrong address.
 - Fix: Ensure Kafka is started and reachable. Run: