What is Metadata?
The first API every client calls after connecting, and re-called on NOT_LEADER or UNKNOWN_TOPIC_OR_PARTITION errors. A surge in Metadata requests signals partition leaders are moving around, typically during rolling restarts, broker failures, or reassignments.
Wire Diagram
Response Header
message_size
int32 · 4B
correlation_id
int32 · 4B
MetadataResponse v0
NodeId
int32 · 4B
Host
string
Port
int32 · 4B
ErrorCode
int16 · 2B
Name
string
ErrorCode
int16 · 2B
PartitionIndex
int32 · 4B
LeaderId
int32 · 4B
ReplicaNodes
[]int32
IsrNodes
[]int32
Schema & Example
Schema { "Brokers": [{ "NodeId": int32, "Host": string, "Port": int32 }], "Topics": [{ "ErrorCode": int16, "Name": string, "Partitions": [{ "ErrorCode": int16, "PartitionIndex": int32, "LeaderId": int32, "ReplicaNodes": [int32], "IsrNodes": [int32] }] }] }
Example { "Brokers": [{ "NodeId": 1, "Host": "broker-1.kafka.local", "Port": 9092 }], "Topics": [{ "ErrorCode": 0, "Name": "orders", "Partitions": [{ "ErrorCode": 0, "PartitionIndex": 3, "LeaderId": 1, "ReplicaNodes": [0, 1, 2], "IsrNodes": [0, 1, 2] }] }] }