All Products
Search
Document Center

ApsaraMQ for Kafka:Query messages

Last Updated:Sep 15, 2025

If you cannot consume a message or experience message loss or delays in ApsaraMQ for Kafka, use the message query feature to view message details and properties for troubleshooting. If you know the partition ID and message offset, query the message by offset. If you do not know the message location but know when it was sent, query the message by time.

Notes

  • The ApsaraMQ for Kafka console displays a maximum of 1 KB of content for each queried message. Content that exceeds 1 KB is automatically truncated. To view the complete message content, you can download the message. The maximum size of a downloaded message is 10 MB. If a message is larger than 10 MB, only the first 10 MB of its content is downloaded.

  • A maximum of 10 messages are displayed in the query results, and their total size cannot exceed 10 MB.

    • For example, if the total size of the first three messages exceeds 10 MB, only the first two messages are displayed.

    • If the total size of 10 messages is less than 10 MB, all 10 messages are displayed.

  • Whether you can query a message depends on the message cleanup policies of ApsaraMQ for Kafka:

    • If disk usage is lower than 75%, messages that exceed the message retention period are deleted at 04:00 every day.

    • If disk usage is between 75% and 85% (exclusive), messages that exceed the message retention period are deleted until disk usage drops below 75%.

    • If disk usage is between 85% and 90% (exclusive), the earliest stored messages are purged, regardless of their retention period.

    • If disk usage is 90% or higher, write protection is enabled to ensure service stability. New messages cannot be written.

    Important

    When ApsaraMQ for Kafka purges messages, it retains at least one storage file. Therefore, you may be able to query messages that have exceeded their retention period.

Query messages by offset

  1. Log on to the ApsaraMQ for Kafka console.

  2. In the Resource Distribution section of the Overview page, select the region where the ApsaraMQ for Kafka instance that you want to manage resides.

  3. On the Instances page, click the name of the instance that you want to manage.

  4. In the navigation pane on the left, click Message Query.

  5. On the Message Query page, select Search by offset from the Search Method drop-down list.

  6. In the Topic list, select a topic. In the Partition list, select a partition. In the Offset text box, enter the message offset and click Search.

    The results show the message at the specified offset and subsequent messages. For example, if you select partition 5 and set the start offset to 5, the results start from offset 5 in partition 5.

    Table 1. Query result parameters

    Parameter

    Description

    Partition

    The topic partition of the message.

    Offset

    The offset of the message.

    Key

    The message key. The key is converted to a string.

    Value

    The message value, which is the message content. The value is converted to a string.

    Headers

    The header information of the message. It is displayed as key-value pairs, such as [trace-id=123]. If not configured, the default value is [].

    CompressionType

    The compression type used for the message. The default value is none, which indicates no compression.

    Created At

    The message creation time in the ProducerRecord object that is specified by you or included by the client when the message is sent.

    Note
    • If this field is configured, the configured value is displayed.

    • If this field is not configured, the system time when the message was sent is used by default.

    • If the displayed value is in the format 1970/x/x x:x:x, the sending time was configured as 0 or another invalid value.

    • ApsaraMQ for Kafka clients of version 0.9 and earlier do not support configuring this time.

    Actions

    • Click Download Key to download the message key.

    • Click Download Value to download the message content.

Query messages by time

You can query messages from all partitions by time. If you do not know the message location but know the approximate time when it was sent, you can specify a point in time. The query returns messages sent at or after the specified time.

  1. On the Message Query page, select Search by Point in Time from the Search Method drop-down list.

  2. In the Topic list, select a topic. In the Partition list, select a partition. In the Point in Time section, select a time and click Search.

    Messages sent at or after the specified point in time are displayed. For information about the parameters in the query results, see Query result parameters.

    • If you select All Partitions, messages from all partitions are displayed.

    • If you select a specific partition, only messages from that partition are displayed.

References

  • For more information about offsets, see Terms.

  • For more information about message consumption details, see View consumer status.