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 v7
ThrottleTimeMs
int32 · 4B
ClusterId?
string
ControllerId
int32 · 4B
NodeId
int32 · 4B
Host
string
Port
int32 · 4B
Rack?
string
ErrorCode
int16 · 2B
Name
string
IsInternal
bool · 1B
ErrorCode
int16 · 2B
PartitionIndex
int32 · 4B
LeaderId
int32 · 4B
LeaderEpoch
int32 · 4B
ReplicaNodes
[]int32
IsrNodes
[]int32
OfflineReplicas
[]int32
Schema & Example
Schema { "ThrottleTimeMs": int32, "Brokers": [{ "NodeId": int32, "Host": string, "Port": int32, "Rack": string? }], "ClusterId": string?, "ControllerId": int32, "Topics": [{ "ErrorCode": int16, "Name": string, "IsInternal": bool, "Partitions": [{ "ErrorCode": int16, "PartitionIndex": int32, "LeaderId": int32, "LeaderEpoch": int32, "ReplicaNodes": [int32], "IsrNodes": [int32], "OfflineReplicas": [int32] }] }] }
Example { "ThrottleTimeMs": 0, "Brokers": [{ "NodeId": 1, "Host": "broker-1.kafka.local", "Port": 9092, "Rack": null }], "ClusterId": "dQw4w9WgXcQ", "ControllerId": 0, "Topics": [{ "ErrorCode": 0, "Name": "orders", "IsInternal": false, "Partitions": [{ "ErrorCode": 0, "PartitionIndex": 3, "LeaderId": 1, "LeaderEpoch": 17, "ReplicaNodes": [0, 1, 2], "IsrNodes": [0, 1, 2], "OfflineReplicas": [0, 1, 2] }] }] }