The message log management feature automatically pushes operation logs from an ApsaraMQ for RabbitMQ instance to a Simple Log Service Logstore. If an error occurs during message sending, consumption, or acknowledgment, you can query and analyze these logs in Simple Log Service to diagnose the issue.
Prerequisites
You have created an ApsaraMQ for RabbitMQ instance. For more information, see Manage instances.
You have activated Simple Log Service and created a project and a Logstore. For more information, see Resource management overview.
Create the
AliyunServiceRoleForAmqpLogDeliveryservice-linked role and grant it the required permissions when prompted in the console. This role pushes logs to your Simple Log Service.
If you delete the project or Logstore, or revoke permissions from ApsaraMQ for RabbitMQ, log delivery will fail.
Billing
ApsaraMQ for RabbitMQ
You are not charged for using the message log management feature.
Simple Log Service
After ApsaraMQ for RabbitMQ pushes logs to Simple Log Service, you are charged for items like storage, traffic, and requests. For more information, see Billable items of pay-as-you-go.
Log format
Log schema
Parameter | Description |
Action | The request method for the operation. For valid values and descriptions, see Action request methods. |
Code | The status code. Valid values:
|
Info | This field is empty for successful requests. For failed requests, it provides details about the error status code. |
InstanceId | The ID of the ApsaraMQ for RabbitMQ instance. The instance ID is available on the Instance Details or Overview page in the ApsaraMQ for RabbitMQ console. |
Queue | The queue associated with the subscription or message.
|
Property | The message attributes. Valid values:
|
RemoteAddress | The IP address of the client that initiated the operation.
Note This field is not logged if the Action is SendDlqMessage. |
ReqUid | The account ID.
Note This field is not logged if the Action is SendDlqMessage. |
ResourceName | The resource name.
Note This field is not logged if the Action is ConnectionOpen, ConnectionClose, ChannelOpen, or ChannelClose. |
VHost | The vhost name. The name is available on the vhosts page in the ApsaraMQ for RabbitMQ console. |
ConnectionId | The server-side ID that uniquely identifies a connection. Note This field is not logged if the Action is SendDlqMessage. |
ChannelId | The client-generated ID that uniquely identifies a channel within the current connection. Note If the Action is ConnectionOpen or ConnectionClose, this value is null. |
microtime | The timestamp of the request in microseconds. |
_source_ | This is a reserved field in Simple Log Service. For more information, see Reserved fields. |
__tag__:__receive_time__ | This is a reserved field in Simple Log Service. For more information, see Reserved fields. |
__topic__ | This is a reserved field in Simple Log Service. For more information, see Reserved fields. |
Action request methods
Request method | Description |
ConnectionOpen | Establishes a connection. |
ConnectionClose | Closes a connection. |
ChannelOpen | Opens a channel. |
ChannelClose | Closes a channel. |
QueueDeclare | Creates a queue. |
QueueDelete | Deletes a queue. |
ExchangeDeclare | Creates an exchange. |
ExchangeDelete | Deletes an exchange. |
ExchangeBind | Binds a source exchange to a destination exchange. |
ExchangeUnBind | Unbinds a source exchange from a destination exchange. |
QueueBind | Binds a queue to an exchange. |
QueueUnbind | Unbinds a queue from an exchange |
SendMessage | A producer sends a message. |
PushMessage | A broker pushes a message. |
BasicGet | A client pulls a message. |
BasicAck | Acknowledges the consumption of a message. |
BasicConsume | Subscribes to a queue. |
BasicReject | Rejects a message. |
BasicRecover | Redelivers unacknowledged messages. |
BasicNack | Negatively acknowledges a message. |
BasicQos | Limits the number of unacknowledged messages that can be prefetched by a consumer. |
QueuePurge | Removes all messages from a queue. |
DeleteMessage | The server deletes a message after receiving a client's Basic.Ack acknowledgment. |
SendDlqMessage | Sends a dead-letter message. |
Procedure
To push logs from your ApsaraMQ for RabbitMQ instance to Simple Log Service, configure a destination.
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 Log Management.
On the My Resources card, click Authorize Now.
If you have already granted ApsaraMQ for RabbitMQ the permissions to access Simple Log Service, skip this step.
On the Log Management page, select the project and Logstore that you created from the Project Name and Logstore drop-down lists, and then click Enable.
Log on to the Simple Log Service console. Enable and configure field indexes for your logs. For more information, see Create indexes.
Manually add the
__tag__:__receive_time__field and set its alias totimestamp.
Tutorials
Count message send/receive operations by queue to identify high-cost queues
When the ApsaraMQ for RabbitMQ console does not provide queue-level billing breakdowns, you can use the operation logs in Simple Log Service to independently count message operations by queue and locate high-consumption queues, without relying on backend data extraction.
In Simple Log Service, query the operation logs of your ApsaraMQ for RabbitMQ instance and run the following query statement to aggregate the number of
SendMessage,PushMessage, andBasicGetoperations per queue within a specified time range, sorted by operation count in descending order:Action: SendMessage OR Action: PushMessage OR Action: BasicGet | SELECT Queue, Action, COUNT(*) AS operation_count GROUP BY Queue, Action ORDER BY operation_count DESC LIMIT 100Action
Description
SendMessageA producer sends a message to ApsaraMQ for RabbitMQ.
PushMessageThe broker pushes a message to a consumer.
BasicGetA consumer client pulls a message.
The results show which queues have the highest message throughput. Use these results to pinpoint the source of high costs and prioritize optimization without waiting for backend data extraction.
FAQ
Q: Why is there a time difference between the client log timestamp and the server delivery success time in ApsaraMQ for RabbitMQ?
A: To troubleshoot this discrepancy, follow these steps:
Check server-side logs first. Query the operation logs in Simple Log Service to verify that the server delivered the message successfully and without delay. Filter by
Action: PushMessage OR Action: DeleteMessageand confirm that theCodefield value is200. If the server-side logs are normal, the server is not the cause of the time difference.Investigate the client environment. If the server-side logs show no issues, the discrepancy is typically caused by the client side. Check for the following conditions:
Network latency or packet loss: Intermittent network issues between the client and the ApsaraMQ for RabbitMQ service can delay message acknowledgment on the client side.
High CPU usage: A heavily loaded CPU can delay the execution of message-sending methods (for example,
convertAndSend), causing the client-recorded timestamp to lag behind the server's actual delivery time.Frequent Full GC pauses: JVM Full GC events pause all application threads, which can significantly increase the time between invoking a send method and actual message delivery. This causes the client log to record a later timestamp than the server's delivery time.
Q: How do I analyze the cause of an issue after receiving an alarm log or alert notification from ApsaraMQ for RabbitMQ?
A: When you receive an alarm log or alert notification, follow these steps to identify the root cause:
Locate the console link in the alarm log. Alarm logs include a URL that directs you to the relevant monitoring or management page in the cloud console. Find this URL in the alarm log content.
Open the Task Details page. Click the URL in the alarm log to access the Task Details page or the cluster monitoring page directly. This page provides the alarm context, associated metrics, and event timeline to help you diagnose the underlying issue.
Correlate with operation logs. Cross-reference the alarm event timestamp with the operation logs in Simple Log Service to identify correlated message operations (such as connection failures, message rejections, or dead-letter routing) that occurred at the same time and may have contributed to the alarm.