All Products
Search
Document Center

ApsaraMQ for RabbitMQ:Configure message logs

Last Updated:Mar 15, 2024

You can use the message log management feature provided by ApsaraMQ for RabbitMQ to push the message logs of ApsaraMQ for RabbitMQ instances to Simple Log Service. If exceptions occur when a client sends, consumes, or acknowledges messages, you can query and analyze message logs in Simple Log Service to troubleshoot the exceptions.

Prerequisites

  • An ApsaraMQ for RabbitMQ instance is created. For more information, see Manage instances.

  • Simple Log Service is activated, and a project and a Logstore are created in Simple Log Service. For more information, see Resource management overview.

Scenarios

The message log management feature of ApsaraMQ for RabbitMQ can be used in the following scenarios:

  • Troubleshoot exceptions. For example, a message is sent, but the consumer does not receive the message.

  • View information about consumers or the number of times that a message is consumed.

  • View message logs that are generated a month ago or earlier.

Usage notes

  • If you delete the created Simple Log Service project or Logstore or revoke the permissions granted to ApsaraMQ for RabbitMQ, logs cannot be pushed as expected.

  • To facilitate the query of message logs, we recommend that you specify an ID for each message when you use an SDK to send and receive messages. For more information, see How do I specify a message ID?

  • You can configure a logging bucket for each ApsaraMQ for RabbitMQ instance. By default, logging buckets are not configured.

  • After the message logs of ApsaraMQ for RabbitMQ are pushed to Simple Log Service, you are charged for items such as storage space, traffic, and the number of requests in Simple Log Service. For more information, see Billable items of pay-by-feature.

Procedure

Configure a logging bucket for the ApsaraMQ for RabbitMQ instance that you created to push logs to Simple Log Service.

  1. Log on to the ApsaraMQ for RabbitMQ console. In the left-side navigation pane, click Instances.

  2. In the top navigation bar of the Instances page, select the region where the instance that you want to manage resides. Then, in the instance list, click the name of the instance that you want to manage.

  3. In the left-side navigation pane, click Logs.

  4. (Optional): On the Service-linked Role for Message Queue for RabbitMQ page, click Authorize.

    If ApsaraMQ for RabbitMQ is granted the permissions to access cloud resources, skip this step.

    pg_access

  5. On the Logs page, select the project to which you want to push message logs from the Project Name drop-down list, select the Logstore to which you want to push message logs from the Logstore drop-down list, and then click Enable.

What to do next

  1. Use an ApsaraMQ for RabbitMQ SDK to send and receive messages. For more information, see Overview.

  2. Query messages. For more information, see Query messages.

  3. Log on to the Simple Log Service console to query and analyze logs. For more information, see Query and analyze logs.

    The following figure provides an example of query results.

    log_result

    Parameter

    Description

    Action

    The operation that was performed. Valid values:

    • MessagePublish: Publish a message.

    • MessageAck: Acknowledge a message.

    • MessageReceived: Consume a message.

    Code

    The returned status code. Valid values:

    • 200: The request is successful.

    • 541: An internal error occurred on the broker.

    • 503: The command is invalid.

    • 530: The operation is not allowed.

    • 404: The resource does not exist.

    • 406: The precheck failed.

    • 403: A permission error occurred.

    Exchange

    The exchange name. You can view the exchange name on the Exchanges page in the ApsaraMQ for RabbitMQ console.

    Info

    This parameter is empty if a request is successful. Otherwise, the information about the returned status code appears.

    InstanceId

    The ID of the ApsaraMQ for RabbitMQ instance. You can view the instance ID on the Instance Details or Overview page in the ApsaraMQ for RabbitMQ console.

    MessageId

    The message ID that you specified when you sent the message by using an SDK.

    OwnerUid

    The ID of the Alibaba Cloud account. You can obtain the account ID in the Alibaba Cloud Management Console.

    Queues

    The 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 you set the Action parameter to MessageAck, the value of this parameter is the unique message ID that is automatically generated by the system.

    RemoteAddress

    • If you set the Action parameter to MessagePublish, the value of this parameter is the IP address of the producer client.

    • If you set the Action parameter to MessageAck, the value of this parameter is the IP address of the consumer client.

    • If you set the Action parameter to MessageReceived, the value of this parameter is the IP address of the consumer client.

    ReqUid

    • If you use a Resource Access Management (RAM) user to send and receive messages, the value of this parameter is the ID of the RAM user.

    • If you use an Alibaba Cloud account to send and receive messages, the value of this parameter is the ID of the Alibaba Cloud account.

    Routingkey

    The routing key that you specified when you sent the message by using an SDK.

    VHost

    The vhost name. You can view the vhost name on the vhosts page in the ApsaraMQ for RabbitMQ console.

    _source_

    A reserved field of Simple Log Service. For more information, see Reserved fields.

    __tag__:__receive_time__

    A reserved field of Simple Log Service. For more information, see Reserved fields. For information about how to collect statistics on message traces based on this field, see Query TPS charts.

    __topic__

    A reserved field of Simple Log Service. For more information, see Reserved fields.