View logs in Simple Log Service
Simple Message Queue (formerly MNS) supports pushing logs to Simple Log Service. This topic describes how to query specific information after the logs are pushed and provides examples for several common query scenarios. You can combine multiple keywords to create more complex queries.
Step 1: Configure an index
Log on to the Simple Log Service console.
In the Projects section, click the project you want.
On the tab, click the logstore you want.
On the Query and Analysis page of the Logstore, click Enable Index.
NoteThe latest data is available for query approximately one minute after you enable indexing.

After you click Enable Index, the full-text index is enabled by default. On the Query and Analysis page, click Auto Generate Index. Simple Log Service automatically generates field indexes based on the first log entry in the data preview.
NoteKeep the default values for other configuration items. For more information, see Create an index.

The following is the generated field index configuration:

Query the message trace of a queue message
Log on to the Simple Log Service console.
In the Projects section, click the one you want.

On the tab, click the logstore you want.

Enter a query statement, and then click Last 15 Minutes to set the time range for the query.
This example shows how to query the message trace of a queue message. Enter the queue name and message ID in the $QueueName and $MessageId format. For example, enter log and EED287A265726135146E6A9CADC880FA.
The following figure shows the query result. The result records the lifecycle of a message from the time it is sent until it is received.

Query the number of sent queue messages
Log on to the Simple Log Service console.
In the Projects section, click the one you want.

On the tab, click the logstore you want.

Enter a query statement, and then click Last 15 Minutes to set the time range for the query.
This example shows how to query the number of sent queue messages. Enter the queue name and the send operation. The query statement is in the $QueueName and (SendMessage or BatchSendMessage) format. For example, enter log and (SendMessage or BatchSendMessage).
The following figure shows the query result. Within the specified time range, the producer sent three messages to the log queue.

Query the number of consumed queue messages
Log on to the Simple Log Service console.
In the Projects section, click the one you want.

On the tab, click the logstore you want.

Enter a query statement, and then click Last 15 Minutes to set the time range for the query.
This example shows how to query the number of consumed queue messages. Enter the queue name and the consumption operation. The query statement is in the $QueueName and (ReceiveMessage or BatchReceiveMessage) format. For example, enter log and (ReceiveMessage or BatchReceiveMessage).
The following figure shows the query result. Within the specified time range, 12 messages were consumed from the log queue.

Query the number of deleted queue messages
Log on to the Simple Log Service console.
In the Projects section, click the one you want.

On the tab, click the logstore you want.

Enter a query statement, and then click Last 15 Minutes to set the time range for the query.
This example shows how to query the number of deleted queue messages. Enter the queue name and the delete operation. The query statement is in the $QueueName and (DeleteMessage or BatchDeleteMessage) format. For example, enter log and (DeleteMessage or BatchDeleteMessage).
The following figure shows the query result. Within the specified time range, 61 messages were deleted from the log queue.

Query the message trace of a topic message
Log on to the Simple Log Service console.
In the Projects section, click the one you want.

On the tab, click the logstore you want.

Enter a query statement, and then click Last 15 Minutes to set the time range for the query.
This example shows how to query the message trace of a topic message. Enter the topic name and message ID. The query statement is in the $TopicName and $MessageId format. For example, enter logtest and 8798453B65727FC6433E6AB4F746D4CE.
The following figure shows the query result. The result records the lifecycle of a message from the time it is sent until it is delivered.

Query the number of published topic messages
Log on to the Simple Log Service console.
In the Projects section, click the one you want.

On the tab, click the logstore you want.

Enter a query statement, and then click Last 15 Minutes to set the time range for the query.
This example shows how to query the number of published topic messages. Enter the topic name and the publish operation. The query statement is in the $TopicName and PublishMessage format. For example, enter logtest and PublishMessage.
The following figure shows the query result. Within the specified time range, the producer published three messages to the logtest topic.

Query the number of messages processed by a client
Log on to the Simple Log Service console.
In the Projects section, click the one you want.

On the tab, click the logstore you want.

Enter a query statement, and then click Last 15 Minutes to set the time range for the query.
This example shows how to query the number of messages processed by a client. Enter the client IP address. The query statement is in the $ClientIP format. For example, enter 10.10.10.0.
If you want to query a specific type of operation log for a client, you can combine multiple keywords. For example, use $ClientIP and (SendMessage or BatchSendMessage).
The following figure shows the query result. Within the specified time range, the client processed 66 messages.







