Public documentation
Documentation indexRead as MarkdownKafka
Use producer/consumer instrumentation to trace messages and the Collector
kafka_metrics receiver to observe broker, topic, partition, and consumer-group
state. In Contrib 0.160.0 the metrics receiver is beta and its canonical type is
kafka_metrics; kafkametrics is a deprecated alias.
The separate kafka receiver consumes telemetry encoded in Kafka topics.
It is not a replacement for broker monitoring and does not trace arbitrary
application messages automatically.
Trace producer and consumer work
Configure the Java agent on both applications when using supported Kafka clients. For other libraries, use the relevant language setup and verify driver support. Give producer and consumer services distinct names.
Send one non-sensitive test message through the normal producer, then process it with the instrumented consumer. Preserve propagation headers through relays and message transformations. Batch processing may use span links; do not require every consumer span to be a direct child in one trace to accept valid instrumentation. Record destination and operation, not the message payload or high-cardinality keys.
Prepare monitoring access
Create a dedicated broker principal with authenticated, encrypted access. Have the Kafka administrator grant only the relevant Describe permissions on the cluster, monitored topics, and consumer groups. Broader optional metrics can require DescribeConfigs; do not grant topic Write or cluster administration just to read lag. Discovery and managed-service ACL behavior need validation against your broker configuration.
Restrict both topic and group collection. The example selects a pre-existing
test topic/group named otel-smoke; replace them with reviewed production names
after verification. The Collector must reach broker addresses returned in
metadata, not only the bootstrap listener.
Add metrics collection
Merge this partial fragment into common setup, retaining
the existing pipelines. Requires Contrib's kafka_metrics and resource components.
receivers:
kafka_metrics/orders:
brokers: [kafka.internal:9093]
scrapers: [brokers, topics, consumers]
collection_interval: 30s
topic_match: '^otel-smoke$'
group_match: '^otel-smoke$'
tls:
ca_file: /etc/otel/certs/kafka-ca.pem
auth:
sasl:
username: otel_monitor
password: ${env:KAFKA_MONITOR_PASSWORD}
mechanism: SCRAM-SHA-512
processors:
resource/kafka:
attributes:
- key: service.name
value: kafka-orders
action: upsert
- key: deployment.environment.name
value: production
action: upsert
service:
pipelines:
metrics/kafka:
receivers: [kafka_metrics/orders]
processors: [memory_limiter, resource/kafka, batch]
exporters: [otlp_http/corridora]
Use the SASL mechanism actually configured on your broker. Supply its secret and CA in the Collector runtime. This receiver does not collect every broker JVM metric; JMX/runtime collection is a separate configuration.
Verify
Prepare a protected monitor.properties file with the monitor's TLS/SASL
settings for Kafka's command-line tools. From the Collector network, run:
kafka-topics.sh --bootstrap-server kafka.internal:9093 \
--command-config monitor.properties --describe --topic otel-smoke
kafka-consumer-groups.sh --bootstrap-server kafka.internal:9093 \
--command-config monitor.properties --describe --group otel-smoke
Expect the intended topic and group's metadata. A group must exist and have committed offsets for its lag to be meaningful. Use the application's own test credentials, not the monitor, to produce and consume the test message.
Validate the Collector and wait two intervals. In Corridora Metrics, select
kafka-orders and inspect kafka.brokers, kafka.topic.partitions, and
kafka.consumer_group.lag. Compare lag to the group command, allowing for time
and commits. Then find the application's producer/consumer spans separately.
For missing groups, inspect ACLs, filters, and committed offsets. For connection timeouts after a successful bootstrap, inspect advertised broker addresses. Zero lag does not prove successful business processing after an early offset commit. Finish with verification.
Source basis: Kafka Metrics receiver README/configuration/metadata, Contrib 0.160.0; Apache Kafka 4.0 Authorization and ACLs; OpenTelemetry Java supported libraries. Reviewed 2026-09-28.