Skip to content

Configuration Manual for the "Alibaba Cloud - RDS Slow Query Statistics Logs" Collector

Before reading this article, please read:

Before using this collector, you must install the 'Integration Core Package' and its associated third-party dependency packages

This script's code execution depends on RDS instance object collection. If custom object collection for RDS is not configured, the slow log script will not be able to collect slow log data.

Due to a 6~8 hour delay in Alibaba Cloud statistical data returns, there may be delays in the collector updating data. For more details, refer to the Alibaba Cloud documentation: Cloud Database RDS Slow Log Query Statistics.

This collector supports all versions of MySQL (except the basic version of MySQL 5.7), SQL Server 2008 R2, MariaDB 10.3 type databases. To collect other types of databases, please use the Alibaba Cloud - RDS Slow Query Details collector.

1. Configuration Structure

The configuration structure for this collector is as follows:

Field Type Required Description
regions list Required List of regions to be collected
regions[#] str Required Region ID. Example: 'cn-hangzhou'
Full table in appendix

2. Configuration Example

Specified Regions

Collect data from Hangzhou and Shanghai regions.

Python
1
2
3
collector_configs = {
    'regions': [ 'cn-hangzhou', 'cn-shanghai' ]
}

3. Data Reporting Format

After the data has been synchronized successfully, it can be viewed in the 'LOG' section of TrueWatch.

Example of reported data:

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
  "measurement": "aliyun_rds_slowlog",
  "tags": {
    "name"                 : "rm-xxxxx",
    "DBName"               : "cloudcare_core",
    "DBInstanceId"         : "rm-bp1xxxxxxxxxx",
    "RegionId"             : "cn-hangzhou",
    "DBInstanceType"       : "Primary",
    "PayType"              : "Prepaid",
    "Engine"               : "MySQL",
    "DBInstanceClass"      : "rds.mysql.s2.large",
    "ZoneId"               : "cn-shanghai-h",
    "DBInstanceDescription": "Business System"
  },
  "fields": {
    "SQLHASH"                      : "436f9dd030e0a87920bbcd818b34f271",
    "SQLText"                      : "{SQL Statement}",
    "CreateTime"                   : "2022-06-05Z",
    "SQLServerTotalExecutionTimes" : 0,
    "MaxExecutionTime"             : 1,
    "MaxLockTime"                  : 0,
    "AvgExecutionTime"             : 0,
    "MySQLTotalExecutionTimes"     : 0,
    "SQLServerTotalExecutionTimes" : 1,
    "SQLServerTotalExecutionCounts": 0,
    "MySQLTotalExecutionCounts"    : 0,
    "SQLServerAvgExecutionTime"    : 0,
    "message"                      : "{JSON Serialized Log Data}"
  }
}

Descriptions of some parameters are as follows:

Field Type Description
SQLServerTotalExecutionTimes int SQL Server execution duration (total value, milliseconds)
AvgExecutionTime int Execution time (average value) unit: seconds
SQLServerAvgExecutionTime int Execution time (average value) unit: seconds
MySQLTotalExecutionTimes int MySQL execution time (total value) unit: seconds
SQLServerTotalExecutionTimes int SQL Server execution time (total value) unit: milliseconds
SQLServerTotalExecutionCounts int SQL Server execution count (total value)
MySQLTotalExecutionCounts int MySQL execution count (total value)

Fields such as AvgExecutionTime, SQLServerAvgExecutionTime, SQLServerTotalExecutionTimes, etc., are only supported by SQL Server instances.

The fields in tags and fields may change with subsequent updates.

fields.message is a JSON serialized string.

X. Appendix

Please refer to the official Alibaba Cloud documentation: