The message log management feature of ApsaraMQ for RabbitMQ allows you to push the message logs of ApsaraMQ for RabbitMQ instances to Simple Log Service Logstores. If errors occur during message sending, consumption, or acknowledgment, you can query and analyze message logs in Simple Log Service to troubleshoot the errors.
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. For more information, see Resource management overview.
The service-linked role
AliyunServiceRoleForAmqpLogDelivery
is created and the required permissions are granted to the role. ApsaraMQ for RabbitMQ can assume the role to push message logs to Simple Log Service.
If you delete the created Simple Log Service project or Logstore or revoke the permissions granted to ApsaraMQ for RabbitMQ, message logs cannot be pushed as expected.
Billing
ApsaraMQ for RabbitMQ
You are not charged for using the message log management feature of ApsaraMQ for RabbitMQ.
Simple Log Service
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.
Log format
Log format description
Parameter | Description |
Action | The request method that corresponds to the operation. For more information, see Request methods. |
Code | The status code. Valid values:
|
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 that is specified in the subscription or the queue in which one or more messages are rejected or negatively acknowledged.
|
Property | The message attribute. Valid values:
|
RemoteAddress | The IP address of the client from which the operation is initiated.
Note If the value of the Action parameter is SendDlqMessage, this parameter is not returned. |
ReqUid | The account ID.
Note If the value of the Action parameter is SendDlqMessage, this parameter is not returned. |
ResourceName | The resource name.
Note If the value of the Action parameter is ConnectionOpen, ConnectionClose, ChannelOpen, or ChannelClose, this parameter is not returned. |
VHost | The vhost name. You can view the vhost name on the vhosts page in the ApsaraMQ for RabbitMQ console. |
ConnectionId | The connection ID. The ID is assigned by the broker to uniquely identify the connection. Note If the value of the Action parameter is SendDlqMessage, this parameter is not returned. |
ChannelId | The channel ID. The ID is generated by the client to uniquely identify the channel in the connection. Note If the value of the Action parameter is ConnectionOpen or ConnectionClose, an empty value is returned. |
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. |
__topic__ | A reserved field of Simple Log Service. For more information, see Reserved fields. |
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 source exchange to a destination queue. |
QueueUnbind | Unbinds a source exchange from a destination queue. The binding that you remove contains the code |
SendMessage | Sends a message from a producer. |
PushMessage | Pushes a message from a broker. |
BasicGet | Pulls a message from a client. |
BasicAck | Acknowledges the consumption of a message. |
BasicConsume | Subscribes to a message in a queue. |
BasicReject | Rejects a message. |
BasicRecover | Redelivers unacknowledged messages. |
BasicNack | Negatively acknowledges one or more messages. |
BasicQos | Limits the number of unacknowledged messages that can be prefetched by a consumer. |
QueuePurge | Removes all messages from a queue. |
DeleteMessage | Deletes a message. If the client calls the BasicAck method after the DeleteMessage method is called, the broker confirms that the message is deleted. |
SendDlqMessage | Sends a message to a dead-letter queue. |
Procedure
Configure a logging bucket for the ApsaraMQ for RabbitMQ instance that you created to push message 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 Log Management.
(Optional) On the Service-linked Role for Message Queue for RabbitMQ page, click Authorize.
If ApsaraMQ for RabbitMQ is authorized to access Simple Log Service, skip this step.
On the Log Management 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.
Log on to the Simple Log Service console and configure indexes for log fields. For more information, see Create indexes.
Add the
__tag__:__receive_time__
field, specify timestamp as the alias, and then configure an index for the field, as shown in the following figure.