Updated on 2025-08-21 GMT+08:00

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.

Video Tutorial

This video shows how to view Kafka messages.

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 or key, 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.
  • To query messages in all partitions, a maximum of 500 records can be returned.
  • The console displays messages smaller than 4 KB. To view messages larger than 4 KB, click Download Message.

Procedure

  1. Log in to the Kafka console.
  2. Click in the upper left corner to select the region where your instance is located.
  3. Click the desired instance to go to the instance details page.
  4. In the left navigation pane, choose Instance > Message Query.
  5. 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.
      Table 1 Querying messages by offset

      Parameter

      Description

      Topic Name

      Name of the topic to be queried.

      Partition

      Partition where the message is located.

      Offset

      Offset of the message.

    • 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.

      Constraints on partition-based message query:

      • Query in all partitions: Due to resource and performance limitations, a maximum of 500 messages can be returned, and the total size of all messages cannot exceed 200 MB.

        Process of obtaining 500 messages: The system pulls the latest 500 messages from each partition in sequence (starting from partition 0) until the total size of pulled messages exceeds 200 MB. The queried messages are sorted by time, and the latest 500 messages are returned.

      • Query in a single partition: All messages in the queried time period are returned, without the limit of 500 messages or 200 MB.

      To query more messages, shorten the query time range or specify partitions.

      Key

      Enter a message key to search for messages containing it.

      For example, a topic contains two messages whose keys are abc and abcd. Enter "abc" in the Key box. The two messages are returned.

      Query with a key: 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 key are returned.

      Content

      Multiple query conditions can be set. Query results meet all of them.

      To set a query condition:

      1. In the Content box, left-click and choose or ×.
      2. Enter a keyword in the message body and press Enter.
      3. To set multiple conditions, repeat 1 to 2.

      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.

  6. Click Search to query messages.

    The query result is as follows.

    Figure 1 Querying topic messages
    Table 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.

  7. 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.

  8. (Optional) To restore the default settings, click Reset.