Collector 'Alibaba Cloud-RDS Slow Query Logs' Configuration Manual¶
Before reading this document, please read:
Tip
Before using this collector, you must install the 'Integration Core Package' and its accompanying third-party dependencies.
Tip
The code execution of this script depends on the RDS instance object collection. If the custom object collection for RDS is not configured, the slow log script cannot collect slow log data.
1. Configuration Structure¶
The configuration structure of this collector is as follows:
Field | Type | Required | Description |
---|---|---|---|
regions |
list | Required | List of regions to be collected |
regions[#] |
str | Required | Region ID. For example: 'cn-hangzhou' See appendix for full list |
engine_types |
list | Optional | Database types to be collected |
engine_types[#] |
str | Required | Database type. For example: 'MySQL' |
Tip
Due to the large volume of detailed slow log data, it is recommended to configure the engine_types parameter.
Tip
engine_types optional parameters: MySQL, PostgreSQL, SQLServer, MariaDB
2. Configuration Examples¶
Specify Region¶
Collect data from Hangzhou and Shanghai regions.
Specify Database Type¶
Collect data from MySQL
and PostgreSQL
type databases.
3. Data Reporting Format¶
After data is successfully synchronized, you can view the data in the 'LOG' section of TrueWatch.
An example of the reported data is as follows:
{
"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",
"HostAddress" : "xxxx",
"UserName" : "xxxx",
"ClientHostName" : "xxxx",
"ApplicationName" : "xxxx",
},
"fields": {
"SQLHASH" : "436f9dd030e0a87920bbcd818b34f271",
"SQLText" : "{SQL Statement}",
"QueryTimes" : 0,
"QueryTimesMS" : 0,
"ReturnRowCounts" : 0,
"ParseRowCounts" : 0,
"ExecutionStartTime" : "2022-02-02T12:00:00Z",
"CpuTime" : 1,
"RowsAffectedCount" : 0,
"LastRowsAffectedCount": 0,
"message" : "{Log JSON Data}"
}
}
Some parameter descriptions are as follows:
Field | Type | Description |
---|---|---|
QueryTimes |
int | Execution duration. Unit: seconds (s) |
QueryTimesMS |
int | Execution duration. Unit: milliseconds (ms) |
ReturnRowCounts |
int | Returned rows |
ParseRowCounts |
int | Parsed rows |
ExecutionStartTime |
str | Execution start time |
CpuTime |
int | CPU processing time |
RowsAffectedCount |
int | Affected rows |
LastRowsAffectedCount |
int | Last statement affected rows |
Note
Fields such as CpuTime, RowsAffectedCount, LastRowsAffectedCount are only supported by SQL Server instances.
Note
Fields in tags and fields may change with subsequent updates.
Tip
fields.message is a JSON serialized string.
X. Appendix¶
Please refer to the official Alibaba Cloud documentation: