This topic describes how to query approximate TPS charts based on message logs of Message Queue for RabbitMQ instances. When the TPS of your business exceeds the purchased specifications for Peak TPS, you can query second-level TPS charts to efficiently identify errors. Then, you can troubleshoot the errors at the earliest opportunity to ensure the proper running of your business.

Prerequisites

Log on to the Message Queue for RabbitMQ console and push message logs of your Message Queue for RabbitMQ instance to Log Service. For more information, see Configure message logging settings.

Background information

  • CloudMonitor provides the average of minute-level statistics for Message Queue for RabbitMQ, but cannot provide second-level TPS data. This topic provides a method to query second-level TPS charts. You must push message logs of your Message Queue for RabbitMQ instance to Log Service, configure indexes in Log Service, and then use analytic statements provided by Log Service to query TPS charts.
  • The TPS of Message Queue for RabbitMQ counts the number of calls to Advanced Message Queuing Protocol (AMQP) methods that clients initiate per second. Table 1 lists the AMQP methods.
    Table 1. AMQP methods
    Method Description
    ConnectionOpen Establishes a connection.
    ChannelOpen Establishes a channel.
    Note The output of the ChannelOpen method is not printed in logs. Therefore, the TPS calculated based on logs in Log Service does not include the number of calls to this method. Therefore, the TPS calculated by configuring indexes in Log Service is less than the number of requests that are actually initiated.
    MessagePublish Publishes a message.
    MessageReceived Subscribes to a message.
    Note For the MessageReceived method, the TPS counts only the requests initiated in pull mode. The TPS does not count the requests initiated in push mode.
    MessageAck Acknowledges a message.
    ExchangeDeclare Declares an exchange.
    QueueDeclare Declares a queue.
    QueueBind Binds an exchange to a queue.
    QueueDelete Deletes a queue.
    ExchangeDelete Deletes an exchange.
    QueueUnBind Unbinds an exchange from a queue.

Procedure

  1. Log on to the Log Service console and configure indexes for log fields. For more information, see Configure indexes. In addition to the automatically generated common fields, you must manually add the __tag__:__receive_time__ field and set its alias to timestamp, as shown in the following figure.
    Configure indexes for log fields
  2. Specify the time range to query the TPS, configure the properties of the statistical chart, and then enter an analytic statement provided by Log Service to query the TPS chart. For more information, see Query logs.
    • If you subscribe to messages in push mode by calling the basicConsume method, use the following analytic statement to query the TPS chart. Replace [instanceid] in the statement with the ID of the Message Queue for RabbitMQ instance whose TPS chart you want to query.
      * and Code : 200 and (Action : MessagePublish or Action : MessageAck or Action: ExchangeDeclare or Action: QueueBind or Action : QueueDeclare or Action : QueueDelete or Action : ExchangeDelete or Action : QueueUnBind) | select time_series(timestamp, '1s', '%Y-%m-%d %H:%i:%s', '0') as time, COUNT(*) as count GROUP by time ORDER by time limit 1000000
    • If you subscribe to messages in pull mode by calling the basicGet method, use the following analytic statement to query the TPS chart. Replace [instanceid] in the statement with the ID of the Message Queue for RabbitMQ instance whose TPS chart you want to query.
      * and [instanceid] and Code : 200 and (Action : MessagePublish or Action : MessageAck or Action : MessageReceived or Action: ExchangeDeclare or Action: QueueBind or Action : QueueDeclare or Action : QueueDelete or Action : ExchangeDelete or Action : QueueUnBind) | select from_unixtime (cast(timestamp AS double)) as time, COUNT(*) as count  GROUP by time ORDER by time 
    TPS chart