librdkafka
The Apache Kafka C/C++ client library
|
librdkafka may be configured to emit internal metrics at a fixed interval by setting the statistics.interval.ms
configuration property to a value > 0 and registering a stats_cb
(or similar, depending on language).
The stats are provided as a JSON object string.
Note: The metrics returned may not be completely consistent between brokers, toppars and totals, due to the internal asynchronous nature of librdkafka. E.g., the top level tx
total may be less than the sum of the broker tx
values which it represents.
All fields that contain sizes are in bytes unless otherwise noted.
Fields are represented as follows:
true
or false
.Field | Type | Example | Description |
---|---|---|---|
name | string | "rdkafka#producer-1" | Handle instance name |
client_id | string | "rdkafka" | The configured (or default) client.id |
type | string | "producer" | Instance type (producer or consumer) |
ts | int | 12345678912345 | librdkafka's internal monotonic clock (microseconds) |
time | int | Wall clock time in seconds since the epoch | |
age | int | Time since this client instance was created (microseconds) | |
replyq | int gauge | Number of ops (callbacks, events, etc) waiting in queue for application to serve with rd_kafka_poll() | |
msg_cnt | int gauge | Current number of messages in producer queues | |
msg_size | int gauge | Current total size of messages in producer queues | |
msg_max | int | Threshold: maximum number of messages allowed allowed on the producer queues | |
msg_size_max | int | Threshold: maximum total size of messages allowed on the producer queues | |
tx | int | Total number of requests sent to Kafka brokers | |
tx_bytes | int | Total number of bytes transmitted to Kafka brokers | |
rx | int | Total number of responses received from Kafka brokers | |
rx_bytes | int | Total number of bytes received from Kafka brokers | |
txmsgs | int | Total number of messages transmitted (produced) to Kafka brokers | |
txmsg_bytes | int | Total number of message bytes (including framing, such as per-Message framing and MessageSet/batch framing) transmitted to Kafka brokers | |
rxmsgs | int | Total number of messages consumed, not including ignored messages (due to offset, etc), from Kafka brokers. | |
rxmsg_bytes | int | Total number of message bytes (including framing) received from Kafka brokers | |
simple_cnt | int gauge | Internal tracking of legacy vs new consumer API state | |
metadata_cache_cnt | int gauge | Number of topics in the metadata cache. | |
brokers | object | Dict of brokers, key is broker name, value is object. See brokers below | |
topics | object | Dict of topics, key is topic name, value is object. See topics below | |
cgrp | object | Consumer group metrics. See cgrp below | |
eos | object | EOS / Idempotent producer state and metrics. See eos below |
Per broker statistics.
Field | Type | Example | Description |
---|---|---|---|
name | string | "example.com:9092/13" | Broker hostname, port and broker id |
nodeid | int | 13 | Broker id (-1 for bootstraps) |
nodename | string | "example.com:9092" | Broker hostname |
source | string | "configured" | Broker source (learned, configured, internal, logical) |
state | string | "UP" | Broker state (INIT, DOWN, CONNECT, AUTH, APIVERSION_QUERY, AUTH_HANDSHAKE, UP, UPDATE) |
stateage | int gauge | Time since last broker state change (microseconds) | |
outbuf_cnt | int gauge | Number of requests awaiting transmission to broker | |
outbuf_msg_cnt | int gauge | Number of messages awaiting transmission to broker | |
waitresp_cnt | int gauge | Number of requests in-flight to broker awaiting response | |
waitresp_msg_cnt | int gauge | Number of messages in-flight to broker awaiting response | |
tx | int | Total number of requests sent | |
txbytes | int | Total number of bytes sent | |
txerrs | int | Total number of transmission errors | |
txretries | int | Total number of request retries | |
txidle | int | Microseconds since last socket send (or -1 if no sends yet for current connection). | |
req_timeouts | int | Total number of requests timed out | |
rx | int | Total number of responses received | |
rxbytes | int | Total number of bytes received | |
rxerrs | int | Total number of receive errors | |
rxcorriderrs | int | Total number of unmatched correlation ids in response (typically for timed out requests) | |
rxpartial | int | Total number of partial MessageSets received. The broker may return partial responses if the full MessageSet could not fit in the remaining Fetch response size. | |
rxidle | int | Microseconds since last socket receive (or -1 if no receives yet for current connection). | |
req | object | Request type counters. Object key is the request name, value is the number of requests sent. | |
zbuf_grow | int | Total number of decompression buffer size increases | |
buf_grow | int | Total number of buffer size increases (deprecated, unused) | |
wakeups | int | Broker thread poll loop wakeups | |
connects | int | Number of connection attempts, including successful and failed, and name resolution failures. | |
disconnects | int | Number of disconnects (triggered by broker, network, load-balancer, etc.). | |
int_latency | object | Internal producer queue latency in microseconds. See Window stats below | |
outbuf_latency | object | Internal request queue latency in microseconds. This is the time between a request is enqueued on the transmit (outbuf) queue and the time the request is written to the TCP socket. Additional buffering and latency may be incurred by the TCP stack and network. See Window stats below | |
rtt | object | Broker latency / round-trip time in microseconds. See Window stats below | |
throttle | object | Broker throttling time in milliseconds. See Window stats below | |
toppars | object | Partitions handled by this broker handle. Key is "topic-partition". See brokers.toppars below |
Rolling window statistics. The values are in microseconds unless otherwise stated.
Field | Type | Example | Description |
---|---|---|---|
min | int gauge | Smallest value | |
max | int gauge | Largest value | |
avg | int gauge | Average value | |
sum | int gauge | Sum of values | |
cnt | int gauge | Number of values sampled | |
stddev | int gauge | Standard deviation (based on histogram) | |
hdrsize | int gauge | Memory size of Hdr Histogram | |
p50 | int gauge | 50th percentile | |
p75 | int gauge | 75th percentile | |
p90 | int gauge | 90th percentile | |
p95 | int gauge | 95th percentile | |
p99 | int gauge | 99th percentile | |
p99_99 | int gauge | 99.99th percentile | |
outofrange | int gauge | Values skipped due to out of histogram range |
Topic partition assigned to broker.
Field | Type | Example | Description |
---|---|---|---|
topic | string | "mytopic" | Topic name |
partition | int | 3 | Partition id |
Field | Type | Example | Description |
---|---|---|---|
topic | string | "myatopic" | Topic name |
age | int gauge | Age of client's topic object (milliseconds) | |
metadata_age | int gauge | Age of metadata from broker for this topic (milliseconds) | |
batchsize | object | Batch sizes in bytes. See *Window stats*· | |
batchcnt | object | Batch message counts. See *Window stats*· | |
partitions | object | Partitions dict, key is partition id. See partitions below. |
Field | Type | Example | Description |
---|---|---|---|
partition | int | 3 | Partition Id (-1 for internal UA/UnAssigned partition) |
broker | int | The id of the broker that messages are currently being fetched from | |
leader | int | Current leader broker id | |
desired | bool | Partition is explicitly desired by application | |
unknown | bool | Partition not seen in topic metadata from broker | |
msgq_cnt | int gauge | Number of messages waiting to be produced in first-level queue | |
msgq_bytes | int gauge | Number of bytes in msgq_cnt | |
xmit_msgq_cnt | int gauge | Number of messages ready to be produced in transmit queue | |
xmit_msgq_bytes | int gauge | Number of bytes in xmit_msgq | |
fetchq_cnt | int gauge | Number of pre-fetched messages in fetch queue | |
fetchq_size | int gauge | Bytes in fetchq | |
fetch_state | string | "active" | Consumer fetch state for this partition (none, stopping, stopped, offset-query, offset-wait, active). |
query_offset | int gauge | Current/Last logical offset query | |
next_offset | int gauge | Next offset to fetch | |
app_offset | int gauge | Offset of last message passed to application + 1 | |
stored_offset | int gauge | Offset to be committed | |
committed_offset | int gauge | Last committed offset | |
eof_offset | int gauge | Last PARTITION_EOF signaled offset | |
lo_offset | int gauge | Partition's low watermark offset on broker | |
hi_offset | int gauge | Partition's high watermark offset on broker | |
ls_offset | int gauge | Partition's last stable offset on broker, or same as hi_offset is broker version is less than 0.11.0.0. | |
consumer_lag | int gauge | Difference between (hi_offset or ls_offset) and committed_offset). hi_offset is used when isolation.level=read_uncommitted, otherwise ls_offset. | |
consumer_lag_stored | int gauge | Difference between (hi_offset or ls_offset) and stored_offset. See consumer_lag and stored_offset. | |
txmsgs | int | Total number of messages transmitted (produced) | |
txbytes | int | Total number of bytes transmitted for txmsgs | |
rxmsgs | int | Total number of messages consumed, not including ignored messages (due to offset, etc). | |
rxbytes | int | Total number of bytes received for rxmsgs | |
msgs | int | Total number of messages received (consumer, same as rxmsgs), or total number of messages produced (possibly not yet transmitted) (producer). | |
rx_ver_drops | int | Dropped outdated messages | |
msgs_inflight | int gauge | Current number of messages in-flight to/from broker | |
next_ack_seq | int gauge | Next expected acked sequence (idempotent producer) | |
next_err_seq | int gauge | Next expected errored sequence (idempotent producer) | |
acked_msgid | int | Last acked internal message id (idempotent producer) |
Field | Type | Example | Description |
---|---|---|---|
state | string | "up" | Local consumer group handler's state. |
stateage | int gauge | Time elapsed since last state change (milliseconds). | |
join_state | string | "assigned" | Local consumer group handler's join state. |
rebalance_age | int gauge | Time elapsed since last rebalance (assign or revoke) (milliseconds). | |
rebalance_cnt | int | Total number of rebalances (assign or revoke). | |
rebalance_reason | string | Last rebalance reason, or empty string. | |
assignment_size | int gauge | Current assignment's partition count. |
Field | Type | Example | Description |
---|---|---|---|
idemp_state | string | "Assigned" | Current idempotent producer id state. |
idemp_stateage | int gauge | Time elapsed since last idemp_state change (milliseconds). | |
txn_state | string | "InTransaction" | Current transactional producer state. |
txn_stateage | int gauge | Time elapsed since last txn_state change (milliseconds). | |
txn_may_enq | bool | Transactional state allows enqueuing (producing) new messages. | |
producer_id | int gauge | The currently assigned Producer ID (or -1). | |
producer_epoch | int gauge | The current epoch (or -1). | |
epoch_cnt | int | The number of Producer ID assignments since start. |
This (prettified) example output is from a short-lived producer using the following command: ‘rdkafka_performance -b localhost -P -t test -T 1000 -Y 'cat >> stats.json’`.
Note: this output is prettified using jq .
, the JSON object emitted by librdkafka does not contain line breaks.