This topic describes how to generate metrics precise to the second by using the message log management feature.
Background information
CloudMonitor provides charts that display the average values of minute-level statistics for ApsaraMQ for RabbitMQ instances. CloudMonitor does not provide charts that display transactions per second (TPS), which is statistics calculated per second. The number of requests that clients initiate per second by calling Advanced Message Queuing Protocol (AMQP) methods is used to calculate the TPS of an ApsaraMQ for RabbitMQ instance.
The following items describe the AMQP methods that are involved in TPS calculation:
ConnectionOpen and ChannelOpen
QueueDeclare, QueueDelete, QueueBind, and QueueUnbind
ExchangeDeclare and ExchangeDelete
ExchangeBind and ExchangeUnBind
SendMessage, BasicConsume, BasicGet, BasicAck, BasicReject, BasicNack, and BasicRecover
For more information, see Request methods.
Procedure
Create a Metricstore to store metric data that has been cleansed.
Log on to the Simple Log Service console. In the Projects section of the page that appears, click the name of the project that you want to manage. On the project details page, select the icon and click Create Now.
In the Create Metricstore panel, specify the basic information about the Metricstore that you want to create.
Create a cleansing task.
Go to the Search & Analysis page of the logstore that you want to manage and enter the query statement. In the following example, the error codes of an ApsaraMQ for RabbitMQ instance are cleansed.
* | SELECT Code, count(*) as num, microtime / 1000 / 1000 as timeSecond group by Code, timeSecond limit 1000000
The preceding statement is in the
Search statement/Analytic statement
format. In this format, the search statement specifies the filter conditions and the analytic statement is a standard SQL statement. Data can be written to the Metricstore only if the following items are cleansed from the query result: the labels that you require, the metric value of each label, and the time. In the preceding statement,Code
specifies the label, which is the response code of each request,num
specifies the value of each label, andtimeSecond
specifies the time in seconds.The following figure shows a sample query result.
In the query result, click the Graph tab and then click Save as Scheduled SQL Job. In the Compute Settings step of the wizard that appears, configure the following parameters and click Next.
NoteWhen you configure the preceding parameters, specify the Metricstore that you created for the Source Project/Logstore parameter.
In the Scheduling Settings step, specify the scheduling interval and click OK.
Query the distribution of metric values in the Metricstore.
The following figure shows a sample query result.
(Optional) Integrate data in the Metricstore into Grafana or Simple Log Service and display the data on a dashboard.
For information about how to integrate data into Grafana, see Send time series data from Simple Log Service to Grafana.
For information about the visualization feature of Simple Log Service, see Overview of visualization.
In the preceding example, the error codes of an ApsaraMQ for RabbitMQ instance are cleansed. You can also cleanse other data, such as the messaging rate of each channel on each remote client, the workload and health status of each queue per second, the total number of sent and received messages per second, and the number of calls for each API operation per second.