Instrumenting Kafka

Status: Experimental

This document defines how to apply semantic conventions when instrumenting Kafka.

Kafka Metrics

Description: General Kafka metrics.

NameInstrumentValue typeUnitUnit (UCUM)DescriptionAttribute KeyAttribute Values
messaging.kafka.messagesCounterInt64messages{messages}The number of messages received by the broker.
messaging.kafka.requests.failedCounterInt64requests{requests}The number of requests to the broker resulting in a failure.typeproduce, fetch
messaging.kafka.requests.queueUpDownCounterInt64requests{requests}The number of requests in the request queue.
messaging.kafka.network.ioCounterInt64bytesbyThe bytes received or sent by the broker.statein, out
messaging.kafka.purgatory.sizeUpDownCounterInt64requests{requests}The number of requests waiting in the purgatory.typeproduce, fetch
messaging.kafka.partitions.allUpDownCounterInt64partitions{partitions}The number of partitions in the broker.
messaging.kafka.partitions.offlineUpDownCounterInt64partitions{partitions}The number of offline partitions.
messaging.kafka.partitions.under-replicatedUpDownCounterInt64partition{partitions}The number of under replicated partitions.
messaging.kafka.isr.operationsCounterInt64operations{operations}The number of in-sync replica shrink and expand operations.operationshrink, expand
messaging.kafka.max.lagUpDownCounterInt64messages{messages}Max lag in messages between follower and leader replicas.
messaging.kafka.controllers.activeUpDownCounterInt64controllers{controllers}The number of active controllers in the broker.
messaging.kafka.leader.electionsCounterInt64elections{elections}Leader election rate (increasing values indicates broker failures).
messaging.kafka.leader.unclean-electionsCounterInt64elections{elections}Unclean leader election rate (increasing values indicates broker failures).
messaging.kafka.brokersUpDownCounterInt64brokers{brokers}Number of brokers in the cluster.
messaging.kafka.topic.partitionsUpDownCounterInt64partitions{partitions}Number of partitions in topic.topicThe ID (integer) of a topic
messaging.kafka.partition.current_offsetGaugeInt64partition offset{partition offset}Current offset of partition of topic.topicThe ID (integer) of a topic
partitionThe number (integer) of the partition
messaging.kafka.partition.oldest_offsetGaugeInt64partition offset{partition offset}Oldest offset of partition of topictopicThe ID (integer) of a topic
partitionThe number (integer) of the partition
messaging.kafka.partition.replicas.allUpDownCounterInt64replicas{replicas}Number of replicas for partition of topictopicThe ID (integer) of a topic
partitionThe number (integer) of the partition
messaging.kafka.partition.replicas.in_syncUpDownCounterInt64replicas{replicas}Number of synchronized replicas of partitiontopicThe ID (integer) of a topic
partitionThe number (integer) of the partition

Kafka Producer Metrics

Description: Kafka Producer level metrics.

NameInstrumentValue typeUnitUnit (UCUM)DescriptionAttribute KeyAttribute Values
messaging.kafka.producer.outgoing-bytes.rateGaugeDoublebytes per secondby/sThe average number of outgoing bytes sent per second to all servers.client-idclient-id value
messaging.kafka.producer.responses.rateGaugeDoubleresponses per second{responses}/sThe average number of responses received per second.client-idclient-id value
messaging.kafka.producer.bytes.rateGaugeDoublebytes per secondby/sThe average number of bytes sent per second for a specific topic.client-idclient-id value
topictopic name
messaging.kafka.producer.compression-ratioGaugeDoublecompression ratio{compression}The average compression ratio of record batches for a specific topic.client-idclient-id value
topictopic name
messaging.kafka.producer.record-error.rateGaugeDoubleerror rate{errors}/sThe average per-second number of record sends that resulted in errors for a specific topic.client-idclient-id value
topictopic name
messaging.kafka.producer.record-retry.rateGaugeDoubleretry rate{retries}/sThe average per-second number of retried record sends for a specific topic.client-idclient-id value
topictopic name
messaging.kafka.producer.record-sent.rateGaugeDoublerecords sent rate{records_sent}/sThe average number of records sent per second for a specific topic.client-idclient-id value
topictopic name

Kafka Consumer Metrics

Description: Kafka Consumer level metrics.

NameInstrumentValue typeUnitUnit (UCUM)DescriptionAttribute KeyAttribute Values
messaging.kafka.consumer.membersUpDownCounterInt64members{members}Count of members in the consumer groupgroupThe ID (string) of a consumer group
messaging.kafka.consumer.offsetGaugeInt64offset{offset}Current offset of the consumer group at partition of topicgroupThe ID (string) of a consumer group
topicThe ID (integer) of a topic
partitionThe number (integer) of the partition
messaging.kafka.consumer.offset_sumGaugeInt64offset sum{offset sum}Sum of consumer group offset across partitions of topicgroupThe ID (string) of a consumer group
topicThe ID (integer) of a topic
messaging.kafka.consumer.lagGaugeInt64lag{lag}Current approximate lag of consumer group at partition of topicgroupThe ID (string) of a consumer group
topicThe ID (integer) of a topic
partitionThe number (integer) of the partition
messaging.kafka.consumer.lag_sumGaugeInt64lag sum{lag sum}Current approximate sum of consumer group lag across all partitions of topicgroupThe ID (string) of a consumer group
topicThe ID (integer) of a topic