Viewing Kafka Messages
When messages are lost or fail to be consumed, you can query the content and attributes of specific messages for troubleshooting.
You can view the offset of different partitions, the message size, creation time, and body of messages in topics.
Notes and Constraints
- If a topic contains a large amount of data, an internal service error may be reported when you query messages in a topic with only one replica. You can shorten the time range for query based on the data volume.
- To query with content, due to resource and performance restrictions, a total of 200 MB and 10,000 messages can be queried, and a maximum of 10 messages can be returned.
- The console displays messages smaller than 4 KB. To view messages larger than 4 KB, click Download Message.
Procedure
- Log in to the Kafka console.
- Click
in the upper left corner to select the region where your instance is located.
- Click the desired instance to go to the instance details page.
- In the left navigation pane, choose Message Query.
- Messages can be queried by offset or creation time.
- When the topic partition and offset of the message are known, query the message by offset. For details, see Table 1.
- When the time range of sending the message is known but the message offset is unknown, query the message by creation time. For details, see Table 2.
Table 2 Querying messages by creation time Parameter
Description
Topic Name
Name of the topic to be queried.
Partition
Partition where the message is located.
If no partition is specified, messages in all partitions of the topic are displayed in the query result.
Content
Enter a keyword in the message body.
Query with content: Due to resource and performance limitations, a maximum of 10,000 messages can be searched, and the total size of all messages cannot exceed 200 MB. Only 10 messages containing the keyword are returned.
For large records (> 20 KB per message) or a long period, dump messages for offline query.
Created
Time when a message is created. You can set the time range of messages to be queried.
WARNING:If a topic contains a large amount of data, an internal service error may be reported when you query messages in a topic with only one replica. You can shorten the time range for query based on the data volume.
- Click Search to query messages.
The query result is as follows.
Figure 1 Querying topic messagesTable 3 Message parameters Parameter
Description
Topic Name
Name of the topic where the message is located.
Partition
Partition where the message is located.
Offset
Position of the message in the partition.
Message Size (Byte)
Size of the message.
Created
Time when the message is created. The message creation time is specified by CreateTime when a producer creates messages. If this parameter is not set during message creation, the message creation time is year 1970 by default.
- Click View Message Body. In the displayed View Message Body dialog box, view the message content, including the topic name, partition, offset, creation time, and message body.
The console displays messages smaller than 4 KB. To view messages larger than 4 KB, click Download Message.
- (Optional) To restore the default settings, click Reset.
Related Documents
- To view Kafka messages by calling an API, see Querying Messages.
- Why Is the Message Creation Time Displayed as Year 1970?
- Why Can't I Query Messages on the Console?
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.