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.
Log on to the ApsaraMQ for RabbitMQ console. In the left-side navigation pane, click Instances.
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.
In the left-side navigation pane, click Logs.
(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.
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
Use an ApsaraMQ for RabbitMQ SDK to send and receive messages. For more information, see Overview.
Query messages. For more information, see Query messages.
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.
Parameter
Description
Action
The operation that is performed. Valid values:
SendMessage: The message is sent.
PushMessage: The message is pushed.
BasicAck: The message is acknowledged.
DeleteMessage: The message is consumed.
Code
The 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.
Info
If the request is successful, this parameter is not displayed. If the request fails, the information about the status code is displayed.
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.
Queue
The queue name.
RemoteAddress
If the value of the Action parameter is SendMessage, the value of this parameter is the address of the producer client.
If the value of the Action parameter is PushMessage, the value of this parameter is the address of the consumer client.
If the value of the Action parameter is BasicAck, the value of this parameter is the address of the consumer client.
If the value of the Action parameter is DeleteMessage, the value of this parameter is the 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.
ResourceName
messageId: the message ID that you specified when you sent the message by using an SDK.
exchange: the exchange name. You can view the exchange name on the Exchanges page in the ApsaraMQ for RabbitMQ console.
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.
microtime
The time when the request is initiated. Unit: microseconds.
_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.