Skip to content

Metrics

Kafka JMX, protocol exporter, and recording rule metrics dictionary.

Both metric sources use job=kafka. JMX targets have a role label and collect each JVM’s internal state. Protocol targets lack role and collect logical cluster, topic, partition, and consumer-group state through Kafka protocol. Protocol exporters run on the one or two broker-capable nodes with the lowest kafka_seq. Single-broker clusters run one.

JMX uses an allowlist for standard JVM and selected broker, replication, request-path, and KRaft metrics. It excludes per-client and per-partition MBeans to limit series counts. Protocol exporters provide partition details.


Common Labels

Metric SourceCommon Labels
JMX target (:9404)job, cls, ins, ip, instance, role, node_id
Protocol exporter target (:9308)job, cls, ins, ip, instance

Both target types use job value kafka. Presence of the role label distinguishes JMX from protocol targets.

Some metrics also carry dimensions such as topic, partition, broker, consumergroup, request, version, error, quantile, state, or operation.


Availability and Scrape Metrics

MetricTypeMeaning
kafka_upGauge/RecordingJMX target scrape availability: up{job="kafka",role=~".+"}
kafka_exporter_upGauge/RecordingProtocol exporter target scrape availability: up{job="kafka",role=""}
upGaugeVictoriaMetrics scrape status for the raw target
jmx_scrape_errorGaugeWhether the JMX Exporter’s last scrape errored; healthy value is 0
jmx_scrape_duration_secondsGaugeJMX scrape duration
jmx_scrape_cached_beansGaugeNumber of MBeans cached by the JMX Exporter
scrape_duration_secondsGaugeTime VictoriaMetrics took to scrape the exporter
scrape_samples_scrapedGaugeNumber of samples in this scrape

Protocol Exporter Metrics

Protocol exporters report the same logical cluster state. Before cluster aggregation, deduplicate according to metric meaning. Do not simply sum every ins.

Broker and Topic

MetricTypeKey DimensionsMeaning
kafka_brokersGaugeClusterNumber of brokers discovered by the exporter
kafka_broker_infoGaugeid, address, etc.Broker info, carried on labels with value 1
kafka_topic_partitionsGaugetopicNumber of partitions in a topic
kafka_topic_partition_current_offsetGaugetopic, partitionPartition’s current log end offset
kafka_topic_partition_oldest_offsetGaugetopic, partitionPartition’s current earliest readable offset
kafka_topic_partition_leaderGaugetopic, partitionCurrent leader broker ID; used to spot anomalies when there is no leader
kafka_topic_partition_replicasGaugetopic, partition, brokerThe replica set assigned to a partition
kafka_topic_partition_in_sync_replicaGaugetopic, partition, brokerCurrent ISR members
kafka_topic_partition_under_replicated_partitionGaugetopic, partitionWhether the partition is under-replicated
kafka_topic_partition_leader_is_preferredGaugetopic, partitionWhether the current leader is the preferred replica

current_offset - oldest_offset estimates the retained offset span. It measures neither bytes nor, for compacted topics, an exact message count.

Consumer Group

MetricTypeKey DimensionsMeaning
kafka_consumergroup_membersGaugeconsumergroupCurrent member count of the group
kafka_consumergroup_current_offsetGaugeconsumergroup, topic, partitionGroup’s committed offset
kafka_consumergroup_current_offset_sumGaugeconsumergroup, topicSum of committed offsets
kafka_consumergroup_lagGaugeconsumergroup, topic, partitionPartition-level consumer lag
kafka_consumergroup_lag_sumGaugeconsumergroup, topicConsumer lag aggregated per group/topic

These series may be absent for consumers that never commit offsets, use external offset storage, or have not consumed the topic.

Exporter Itself

MetricTypeMeaning
kafka_exporter_build_infoGaugeExporter version, revision, and build info
process_*Gauge/CounterExporter process CPU, memory, FD, start time, etc.
go_*Gauge/CounterExporter Go runtime, GC, goroutine, and memory state
promhttp_metric_handler_*Counter/metrics request handling status

JMX: JVM Baseline

excludeJvmMetrics: false makes the JMX Exporter expose the standard JVM/process metrics. The Kafka Instance dashboard mainly uses:

MetricMeaning
jvm_memory_used_bytesUsed memory, split by heap/non-heap and memory pool
jvm_memory_committed_bytesJVM committed memory
jvm_memory_max_bytesMaximum memory available to the JVM
jvm_gc_collection_seconds_countGC count
jvm_gc_collection_seconds_sumCumulative GC time
jvm_threads_stateThread count by thread state
jvm_threads_deadlockedNumber of detected deadlocked thread cycles
jvm_buffer_pool_used_bytesDirect/mapped buffer pool usage
process_cpu_seconds_totalCumulative CPU time of the Kafka JVM
process_open_fds / process_max_fdsOpen and maximum file descriptors
process_start_time_secondsKafka JVM start time

JMX: Broker Traffic

MetricTypeMeaning
kafka_server_broker_messages_in_totalCounterTotal messages received by the broker
kafka_server_broker_bytes_in_totalCounterTotal client bytes received by the broker
kafka_server_broker_bytes_out_totalCounterTotal client bytes sent by the broker
kafka_server_broker_replication_bytes_in_totalCounterTotal replication bytes received by the broker
kafka_server_broker_replication_bytes_out_totalCounterTotal replication bytes sent by the broker
kafka_server_broker_produce_requests_totalCounterTotal produce requests
kafka_server_broker_failed_produce_requests_totalCounterTotal failed produce requests
kafka_server_broker_fetch_requests_totalCounterTotal fetch requests
kafka_server_broker_failed_fetch_requests_totalCounterTotal failed fetch requests

Broker totals have no topic dimension. Their JMX series count therefore does not grow with topic count. Protocol exporters provide topic offsets and progress.


JMX: Replication and Storage

MetricTypeMeaning
kafka_server_replica_manager_under_replicated_partitionsGaugeNumber of partitions whose ISR is smaller than the assigned replica set
kafka_server_replica_manager_under_min_isr_partitionsGaugeNumber of partitions whose ISR is below min.insync.replicas
kafka_server_replica_manager_at_min_isr_partitionsGaugeNumber of partitions whose ISR is exactly min.insync.replicas
kafka_server_replica_manager_offline_replicasGaugeNumber of offline replicas on the current broker
kafka_server_replica_manager_partitionsGaugeNumber of replicas hosted by the current broker
kafka_server_replica_manager_leadersGaugeNumber of partitions led by the current broker
kafka_server_replica_manager_isr_shrinks_totalCounterTotal ISR shrink events
kafka_server_replica_manager_isr_expands_totalCounterTotal ISR expand events
kafka_server_replica_manager_failed_isr_updates_totalCounterTotal failed ISR updates
kafka_server_replica_manager_reassigning_partitionsGaugeNumber of leader partitions currently being reassigned
kafka_server_delayed_operation_purgatory_sizeGaugeNumber of delayed operations waiting, split by operation
kafka_log_manager_offline_log_directoriesGaugeNumber of log directories Kafka has marked offline

Under Replicated means some replicas are not synchronized. Under Min ISR means write availability or durability has fallen below the configured minimum. At Min ISR still meets that minimum but has no remaining replica margin.


JMX: Request Path

MetricTypeExtra LabelsMeaning
kafka_network_request_totalCounterrequest, versionTotal requests per Kafka API
kafka_network_request_errors_totalCounterrequest, errorTotal error responses per API/error code
kafka_network_request_total_time_secondsGaugerequest, version, quantileTotal API time at P50/P95/P99
kafka_network_request_queue_sizeGauge—Number of requests waiting for a request handler
kafka_network_response_queue_sizeGauge—Number of responses waiting for a network processor
kafka_server_request_handler_idle_ratioGauge—Average request-handler idle ratio
kafka_network_processor_idle_ratioGauge—Average network-processor idle ratio

For high latency, examine request volume, errors, P95/P99, both queues, thread idle ratios, GC, CPU, disk I/O, and network. A low idle ratio alone cannot locate the bottleneck.


JMX: KRaft and Broker Metadata

MetricTypeMeaning
kafka_server_raft_stateGaugeThe current member’s KRaft state, expressed via the state label
kafka_server_raft_current_leaderGaugeCurrent KRaft leader node ID; -1 means unknown
kafka_server_raft_current_epochGaugeCurrent KRaft epoch
kafka_server_raft_high_watermarkGaugeMetadata log high watermark
kafka_server_raft_log_end_offsetGaugeMetadata log end offset
kafka_server_broker_metadata_last_applied_record_lag_secondsGaugeTime lag of the broker applying metadata records
kafka_server_broker_metadata_load_errors_totalCounterTotal broker metadata load errors
kafka_server_broker_metadata_apply_errors_totalCounterTotal broker metadata image apply errors
kafka_server_metadata_snapshot_bytesGaugeSize of the most recently generated or loaded metadata snapshot
kafka_server_metadata_snapshot_age_secondsGaugeAge of the most recent metadata snapshot

log_end_offset - high_watermark helps estimate metadata commit lag. Also check member role, leader, epoch, and controller event latency.


JMX: Controller

These MBeans exist only in Kafka processes that carry the controller role:

MetricTypeMeaning
kafka_controller_active_controller_countGauge1 on the active controller, 0 on the others
kafka_controller_fenced_broker_countGaugeNumber of fenced brokers observed by the active controller
kafka_controller_active_broker_countGaugeNumber of active brokers
kafka_controller_global_topic_countGaugeNumber of topics observed by the controller
kafka_controller_global_partition_countGaugeNumber of partitions observed by the controller
kafka_controller_offline_partition_countGaugeNumber of offline non-internal partitions
kafka_controller_preferred_replica_imbalance_countGaugeNumber of partitions whose leader is not the preferred replica
kafka_controller_metadata_errors_totalCounterTotal controller metadata processing errors
kafka_controller_last_applied_record_lag_secondsGaugeTime lag of the controller applying metadata records
kafka_controller_timed_out_broker_heartbeats_totalCounterTotal broker heartbeat timeouts
kafka_controller_elections_totalCounterTotal new active-controller elections observed by this node
kafka_controller_unclean_leader_elections_totalCounterTotal unclean leader elections
kafka_controller_event_queue_time_secondsGaugeController event queue time at P50/P95/P99
kafka_controller_event_processing_time_secondsGaugeController event processing time at P50/P95/P99

Healthy clusters should have exactly one active controller. Prioritize increases in offline_partition_count, metadata_errors_total, and unclean_leader_elections_total.


Recording Rule Metrics

Offset Progress

MetricAggregation LevelWindowMeaning
kafka:topic:msg_rate1mTopic1mForward growth rate of current offset, deduplicated across exporters
kafka:topic:msg_rate5mTopic5mForward growth rate of current offset, deduplicated across exporters
kafka:cls:msg_rate1mLogical cluster1mMessage append rate, deduplicated across exporters
kafka:cls:msg_rate5mLogical cluster5mMessage append rate, deduplicated across exporters
kafka:csg_topic:commit_rate5mGroup/Topic5mForward growth rate of commit offset
kafka:csg_topic:lagGroup/TopiccurrentPartition lag, deduplicated and summed
kafka:csg:lagConsumer groupcurrentTotal group lag across topics
kafka:cls:lagLogical clustercurrentTotal cluster lag across consumer groups

JVM and Broker

MetricMeaning
kafka:ins:jvm_heap_used_ratioHeap used / heap max
kafka:ins:jvm_cpu_cores5-minute JVM CPU core consumption
kafka:ins:loadSaturation of the instance’s busiest request thread pool
kafka:cls:loadAverage load across the cluster’s instances
kafka:ins:jvm_gc_time_rate5m5-minute GC time rate
kafka:ins:messages_in_rate5mBroker 5-minute message receive rate
kafka:ins:bytes_in_rate5mBroker 5-minute inbound client byte rate
kafka:ins:bytes_out_rate5mBroker 5-minute outbound client byte rate
kafka:ins:request_error_rate5m5-minute rate of non-NONE request errors
kafka:cls:under_replicated_partitionsTotal under-replicated partitions in the cluster
kafka:cls:offline_partitionsOffline partitions in the cluster

Cardinality and Interpretation Notes

  • Do not directly sum multiple kafka_exporter results for one cls. They can duplicate cluster state.
  • kafka_topic_partition_current_offset measures offsets, not exact bytes, requests, or business events.
  • Consumer lag covers only visible groups with committed offsets.
  • Controller-only nodes normally lack broker and protocol metrics. Unselected brokers normally lack protocol metrics.
  • A JMX series is absent if its MBean does not exist for the Kafka version or role. Interpret this with role.
  • The allowlist excludes per-client and per-partition JMX metrics to limit unpredictable series counts.

For how to use the dashboards and alerts, see Monitoring.