After successfully connecting to Message Queue for Kafka, if a message consumption exception occurs, you can view detailed server-side message content through message query function. You can verify whether the message details on the server-side exactly match those on the producer or consumer side to troubleshoot message issues.
Background information
Message Queue for Kafka provides the following methods to query message details.
- Query by offset. Query messages from the specified topic, partition, and offset. This suits scenarios where the partition ID and message offset are clear.
- Query by time. Query message lists within a specified time range for a specific topic, partition, or all partitions. When querying by time range, messages that meet the criteria are filtered. This suits scenarios where message sending time period is clear.
We recommend that you use message query function in the following scenarios:
- View the specific message content to verify whether it matches the production/consumption end.
- Download the specified message content for further troubleshooting.
Note
- The storage duration of messages in Message Queue for Kafka is determined by the parameter Message retention period. The system regularly deletes messages that exceed this period. During viewing, some messages may expire and be deleted. You can adjust the message expiration and deletion policy by modifying the Message retention period parameter. For details, see Modify parameter configuration.
- When storage space is insufficient, the backend system deletes historical messages. Therefore, some messages may be unavailable for querying.
- Each query displays up to 16 results on the page. The total message content size does not exceed 10 MiB. For example, if the total size of the messages exceeds the 10 MiB limit because the 11th message body is too large, the system only returns the previous 10 results. You can click Load more to see more results. When the data volume is large, we recommend that you narrow the time range and query in batches.
- The console displays up to 1 KiB of content for each retrieved message. Any content beyond 1 KiB will be automatically intercepted. To view the complete message content, download the message to local device.
Prerequisites
Deploy the production-end service. Access Message Queue for Kafka.
Query messages by offset
- Select the region where the instance is located on the top menu bar.
- Click the specified instance name on the Instances page.
- Click Message query on the top tab bar.
- Select Query by offset, and then specify the Topic, Partition, and Offset of the target message.
tip
After setting the Topic and partition, the page will display the selectable range for the offset. You need to set the starting offset within the specified range. Offsets outside this range have no messages to query.
- The page displays a list of messages that matches the filter criteria, including Topic name, partition, offset, key, value, message size, and storage time.
Query messages by time
- Select the region where the instance is located on the top menu bar.
- Click the specified instance name on the Instances page.
- Click Message query on the top tab bar.
- Select Query by time, then set the target message's topic, partition, and message storage period.
tip
Supports two methods: preset time and custom time. Various time periods are preset to facilitate message queries.
- The page displays a list of messages that matches the filter criteria, including Topic name, partition, offset, key, value, message size, and storage time.
Download messages
After finding the specified message, you can download its content on the message query tab. You can troubleshoot production and consumption issues by comparing producer or consumer messages.
tip
Currently, batch message download is not supported.
- Query messages by offset or time.
- In the query results, locate the specified message and click Download message in the Actions column.
- The page automatically downloads message files in .txt format. The file displays full message content.