Skip to content

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

Before reading this, please first read:

Before using this collector, you must install the 'Integration Core Package' and its corresponding 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 be unable to 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 collect data from
regions[#] str Required Region ID. Example: 'cn-hangzhou'
Refer to appendix for full list
engine_types list Optional List of database types to collect data from
engine_types[#] str Required Database type. Example: 'MySQL'

Due to the large volume of detailed slow log data, it is recommended to configure the engine_types parameter

engine_types optional parameters: MySQL, PostgreSQL, SQLServer, MariaDB

2. Configuration Examples

Specify Regions

Collect data from Hangzhou and Shanghai regions.

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

Specify Database Types

Collect data from MySQL, PostgreSQL database types.

Python
1
2
3
collector_configs = {
    'engine_types': [ 'MySQL', 'PostgreSQL']
}

3. Data Reporting Format

After data is synchronized successfully, you can view the data in the TrueWatch "LOGs".

An example of reported data is as follows:

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
31
32
33
{
  "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}"
  }
}

Descriptions of some parameters are as follows:

Field Type Description
QueryTimes int Execution duration. Unit: seconds (s)
QueryTimesMS int Execution duration. Unit: milliseconds (ms)
ReturnRowCounts int Number of returned rows
ParseRowCounts int Number of parsed rows
ExecutionStartTime str Start time of execution
CpuTime int CPU processing duration
RowsAffectedCount int Number of affected rows
LastRowsAffectedCount int Number of affected rows by last statement

Fields such as CpuTime, RowsAffectedCount, LastRowsAffectedCount are only supported by SQL Server instances

Fields in tags, fields may change with subsequent updates

fields.message is a string after JSON serialization

X. Appendix

Please refer to the official Alibaba Cloud documentation: