View logs in Simple Log Service

Updated at:

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.

Important Simple Message Queue (formerly MNS) logs that are pushed to a specified Logstore have a delay of about 3 minutes.

Step 1: Configure an index

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the project you want.

  3. On the Log Storage > Logstores tab, click the logstore you want.

  4. On the Query and Analysis page of the Logstore, click Enable Index.

    Note

    The latest data is available for query approximately one minute after you enable indexing.

    image

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

    Note

    Keep the default values for other configuration items. For more information, see Create an index.

    image

    The following is the generated field index configuration:

    image

Query the message trace of a queue message

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. On the Log Storage > Logstores tab, click the logstore you want.

    image

  4. 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.View the message trace of a queue message

Query the number of sent queue messages

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. On the Log Storage > Logstores tab, click the logstore you want.

    image

  4. 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.View the number of written queue messages

Query the number of consumed queue messages

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. On the Log Storage > Logstores tab, click the logstore you want.

    image

  4. 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.View the consumption volume of queue messages

Query the number of deleted queue messages

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. On the Log Storage > Logstores tab, click the logstore you want.

    image

  4. 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.View the deletion volume of queue messages

Query the message trace of a topic message

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. On the Log Storage > Logstores tab, click the logstore you want.

    image

  4. 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.View the message trace of a topic message

Query the number of published topic messages

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. On the Log Storage > Logstores tab, click the logstore you want.

    image

  4. 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.View the publication volume of topic messages

Query the number of messages processed by a client

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. On the Log Storage > Logstores tab, click the logstore you want.

    image

  4. 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.View the message processing volume of a client