This topic describes how to query MNS logs in the Log Service console. This topic describes several common scenarios of real-time query. You can use multiple keywords to run complex queries.

Notice Logs can be pushed from MNS to Log Service about three minutes after the logs are generated.

Log query and analysis

  1. Log on to the Log Service console.
  2. In the Projects section, click the destination project.
  3. On the Log Storage > Logstores tab, click the destination Logstore.
  4. Enter a query statement in the search box.
    A query statement consists of a search statement and an analytic statement in the format of search statement|analytic statement. For more information, see Search syntax and SQL syntax.
  5. On the Search & Analysis page, click 15 Minutes(Relative) to set the time range for the query.
    You can select a relative time, set a time frame, or customize a time range.
    Note The query results may contain logs that are generated 1 minute earlier or later than the specified time period.
  6. Click Search & Analyze to view the query results.

View the tracing of a message in a queue

  1. Log on to the Log Service console.
  2. In the Projects list, click the project where the message resides.
  3. On the page that appears, choose Log Storage > Logstores, and then click the Logstore in which the message is stored.
  4. Enter a search statement.
    In this example, the message tracing of a message in a queue is queried. You must enter the queue name and the message ID in the format of $QueueName and $MessageId, for example, log and FF973C9C6572630D7F963C527CC5A82C.
  5. In the upper-right corner of the page, click 15 Minutes (Relative) to set a time range for the query.
    You can select a relative time, set a time frame, or customize a time range.
    Note The query results may contain logs that are generated one minute earlier or later than the specified time range.
  6. Click Search & Analyze.
    The following query result records the process from the time when the message is sent to the time when the message is received.View the tracing of a message in a queue

View the number of messages that are sent to Log Service in a queue

  1. Enter a search statement on the Search & Analysis page of the Logstore where the messages are stored.
    In this example, the number of messages sent in a queue is queried. You must enter the queue name and send operation in the format of $QueueName and (SendMessage or BatchSendMessage), for example, log and (SendMessage or BatchSendMessage).
  2. In the upper-right corner of the page, click 15 Minutes (Relative) to set a time range for the query.
    You can select a relative time, set a time frame, or customize a time range.
    Note The query results may contain logs that are generated one minute earlier or later than the specified time range.
  3. Click Search & Analyze.
    The following figure shows the query results. Three queue messages are sent by the message producer to a queue named log in the specified time range.View the number of messages that are sent to Log Service in a queue

View the number of messages that are consumed by Log Service in a queue

  1. Enter a search statement on the Search & Analysis page of the Logstore where the messages are stored.
    In this example, the number of messages that are consumed by Log Service in a queue is queried. You must enter the queue name and consumption operation in the format of $QueueName and (ReceiveMessage or BatchReceiveMessage), for example, log and (ReceiveMessage or BatchReceiveMessage).
  2. In the upper-right corner of the page, click 15 Minutes (Relative) to set a time range for the query.
    You can select a relative time, set a time frame, or customize a time range.
    Note The query results may contain logs that are generated one minute earlier or later than the specified time range.
  3. Click Search & Analyze.

    The following figure shows the query results. Twelve queue messages are consumed in the specified time range.

    View the number of messages that are consumed by Log Service in a queue

View the number of messages that are deleted from a queue

  1. Enter a search statement on the Search & Analysis page of the Logstore where the messages are stored.
    In this example, the number of messages that are deleted from a queue is queried. You must enter the queue name and delete operation in the format of $QueueName and (DeleteMessage or BatchDeleteMessage), for example, log and (DeleteMessage or BatchDeleteMessage).
  2. In the upper-right corner of the page, click 15 Minutes (Relative) to set a time range for the query.
    You can select a relative time, set a time frame, or customize a time range.
    Note The query results may contain logs that are generated one minute earlier or later than the specified time range.
  3. Click Search & Analyze.

    The following figure shows the query results. Sixty-one queue messages are deleted in the specified time range.

    View the number of the messages that are deleted from a queue

View the tracing of a message in a topic

  1. Enter a search statement on the Search & Analysis page of the Logstore where the messages are stored.
    In this example, the message tracing of a message in a topic is queried. You must enter the topic name and MessageId in the format of $TopicName and $MessageId, for example, logtest and 979628CD657261357FCB3C8A68BFA0E3.
  2. In the upper-right corner of the page, click 15 Minutes (Relative) to set a time range for the query.
    You can select a relative time, set a time frame, or customize a time range.
    Note The query results may contain logs that are generated one minute earlier or later than the specified time range.
  3. Click Search & Analyze.
    The following query result records the process from the time when the message is sent to the time when the message is received.View the tracing of a message in a topic

View the number of messages that are published in a topic

  1. Enter a search statement on the Search & Analysis page of the Logstore where the messages are stored.
    In this example, the number of messages that are published in a topic is queried. You must enter the topic name and publish operation in the format of $TopicName and PublishMessage, for example, logtest and PublishMessage.
  2. In the upper-right corner of the page, click 15 Minutes (Relative) to set a time range for the query.
    You can select a relative time, set a time frame, or customize a time range.
    Note The query results may contain logs that are generated one minute earlier or later than the specified time range.
  3. Click Search & Analyze.
    The following figure shows the query results. Three messages are published to the logtest topic in the specified time range.View the number of messages that are published in a topic

View the number of messages that are processed by a client

  1. Enter a search statement on the Search & Analysis page of the Logstore where the messages are stored.
    In this example, the number of messages that are processed by a client is queried. You must enter the client IP address in the format of $ClientIP, for example, 10.10.10.0.

    If you need to query a specific type of operations log, you can use multiple keywords, for example, $ClientIP and (SendMessage or BatchSendMessage).

  2. In the upper-right corner of the page, click 15 Minutes (Relative) to set a time range for the query.
    You can select a relative time, set a time frame, or customize a time range.
    Note The query results may contain logs that are generated one minute earlier or later than the specified time range.
  3. Click Search & Analyze.
    The following figure shows the query results. The client processed 66 messages in the specified time range.View the number of messages that are processed by a client