You can use the message log management feature of Message Queue for RabbitMQ to push message logs of a Message Queue for RabbitMQ instance to Log Service. If errors occur when a client sends, consumes, or acknowledges messages, you can query and analyze message logs in Log Service to troubleshoot the errors.

Prerequisites

Before you push message logs of a Message Queue for RabbitMQ instance to Log Service, make sure that the following operations are complete:

Scenarios

The message log management feature of Message Queue for RabbitMQ is used in the following scenarios:
  • Troubleshoot exceptions. For example, a message is sent, but the consumer does not receive this message.
  • View information about consumers or the number of times a message is consumed.
  • View message logs that were generated a month ago or earlier.

Usage notes

  • If you delete the created project and Logstore or revoke the permissions granted to Message Queue for RabbitMQ, logs cannot be pushed.
  • To facilitate query of message logs, we recommend that you specify the message ID when you use an SDK to send or receive messages. For more information, see How do I specify a message ID?.
  • You can configure logging buckets for each Message Queue for RabbitMQ instance. By default, logging buckets are not configured.
  • After message logs of Message Queue for RabbitMQ are pushed to Log Service, Log Service charges you based on items such as storage space, traffic, and the number of requests. For more information, see Billable items and billing method.

Procedure

Configure a logging bucket for a Message Queue for RabbitMQ instance to push logs to Log Service.

  1. Log on to the Message Queue for RabbitMQ console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance is located.
  3. On the Instances page, click the name of your instance.
  4. In the left-side navigation pane, click Logs.
  5. Optional:On the page, click Authorize.
    If Message Queue for RabbitMQ is granted the permissions to access cloud resources, skip this step.
    pg_access
  6. On the Logs page, select the project to which you want to ship message logs from the Project Name drop-down list, select the Logstore to which you want to ship message logs from the Logstore drop-down list, and then click Enable.

What to do next

  1. Use Message Queue for RabbitMQ SDK to send and subscribe to messages. For more information, see Overview.
  2. Query messages. For more information, see Query messages.
  3. You can log on to the Log Service console to query and analyze logs. For more information, see Query logs.
    Parameter Description
    Action The action. Valid values:
    • MessagePublish: Publishes a message.
    • MessageAck: Acknowledges a message.
    • MessageReceived: Consumes a message.
    Code The status code. Valid values:
    • 200: The request is successful.
    • 541: An internal error occurs.
    • 503: The command is invalid.
    • 530: The operation is not allowed.
    • 404: The resource does not exist.
    • 406: The precheck fails.
    • 403: A permission error occurs.
    Exchange The name of the exchange. You can view the exchange name on the Exchanges page in the Message Queue for RabbitMQ console.
    Info This parameter is left empty if a request is successful. Otherwise, information about the returned HTTP status code appears.
    InstanceId The ID of the Message Queue for RabbitMQ instance. You can view the instance ID on the Instance Details page or Overview page in the Message Queue for RabbitMQ console.
    MessageId The message ID that is specified when you use an SDK to send the message.
    OwnerUid The ID of the Alibaba Cloud account. You can obtain the account ID in the Alibaba Cloud Management Console.
    Queues Information about queues. An information entry consists of the queue name and a unique message ID that is automatically generated by the system. Multiple information entries are separated with vertical bars (|). If the value of the Action parameter is MessageAck, the value of this parameter is the unique message ID automatically generated by the system.
    RemoteAddress
    • If the value of the Action parameter is MessagePublish, the value of this parameter is the address of the producer client.
    • If the value of the Action parameter is MessageAck, the value of this parameter is the address of the consumer client.
    • If the value of the Action parameter is MessageReceived, the value of this parameter is the address of the consumer client.
    ReqUid
    • If you send or receive messages by using a RAM user, the value of this parameter is the ID of the RAM user.
    • If you send or receive messages by using your Alibaba Cloud account, the value of this parameter is the ID of the Alibaba Cloud account.
    Routingkey The routing key that is specified when you use an SDK to send the message.
    VHost The name of the vhost. You can view the vhost name on the vhosts page in the Message Queue for RabbitMQ console.
    _source_ A reserved field of Log Service. For more information about the meaning of this field, see Reserved fields.
    __tag__:__receive_time__ A reserved field of Log Service. For more information about the meaning of this field, see Reserved fields. For more information about how to query statistics about message traces based on this field, see Query TPS charts based on message logs.
    __topic__ A reserved field of Log Service. For more information about the meaning of this field, see Reserved fields.