conduktor.io ↗

Kafka BrokerHeartbeat Request Wire Format v2 — Binary Protocol Layout

What is BrokerHeartbeat?

Each broker sends this periodically to the KRaft controller to prove liveness and report metadata replication progress. A broker that stops heartbeating gets fenced and its leadership migrated away. The highestMetadataOffset tells the controller how caught up the broker is before unfencing after a restart.

Related Errors

BROKER_ID_NOT_REGISTERED · STALE_BROKER_EPOCH

Wire Diagram

Request Header v2 · flexible
message_size int32 · 4B
api_key int16 · 2B
api_version int16 · 2B
correlation_id int32 · 4B
client_id? nullable string · int16 length
tagged var
BrokerHeartbeatRequest v2
BrokerId int32 · 4B
BrokerEpoch int64 · 8B
CurrentMetadataOffset int64 · 8B
WantFence bool · 1B
WantShutDown bool · 1B
tagged var
Known optional payloads inside tagged buffer
tag 0: OfflineLogDirs []uuid
tag 1: CordonedLogDirs []uuid

Schema & Example

Schema
{
  "BrokerId": int32,
  "BrokerEpoch": int64,
  "CurrentMetadataOffset": int64,
  "WantFence": bool,
  "WantShutDown": bool,
  "OfflineLogDirs": [uuid],
  "CordonedLogDirs": [uuid]?
}
Illustrative values (not encoded bytes)
{
  "BrokerId": 1,
  "BrokerEpoch": 12,
  "CurrentMetadataOffset": 150382,
  "WantFence": true,
  "WantShutDown": true,
  "OfflineLogDirs": ["550e8400-e29b-41d4-a716-446655440000", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"],
  "CordonedLogDirs": ["550e8400-e29b-41d4-a716-446655440000", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"]
}