Skip to content

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

Before reading this, please refer to:

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 PolarDB instance object collection. If PolarDB custom object collection is not configured, the slow log script will not be able 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'
See appendix for full list

2. Configuration Example

Specifying Regions

Collect data from Hangzhou region

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

3. Data Reporting Format

After the data has been synchronized successfully, it can be viewed in the 'LOGs' 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
{
  "measurement": "aliyun_polardb_slowlog",
  "tags": {
    "DBName"  : "PolarDB_MySQL",
    "DBNodeId": "pi-***************"
  },
  "fields": {
    "CreateTime"          : "2023-05-22Z",
    "MaxExecutionTime"    : 60,
    "MaxLockTime"         : 1,
    "ParseMaxRowCount"    : 1,
    "ParseTotalRowCounts" : 2,
    "ReturnMaxRowCount"   : 3,
    "ReturnTotalRowCounts": 1,
    "SQLHASH"             : "U2FsdGVkxxxx",
    "SQLText"             : "select id,name from tb_table",
    "TotalExecutionCounts": 2,
    "TotalExecutionTimes" : 2,
    "TotalLockTimes"      : 1,
    "message"             : "{JSON log data}"
  }
}

Descriptions of some parameters are as follows:

Field Type Description
MaxExecutionTime Long Execution duration (maximum value), unit: seconds
TotalExecutionTimes Long Execution duration (total value), unit: seconds
TotalLockTimes Long Lock duration (total value), unit: seconds
MaxLockTime Long Lock duration (maximum value), unit: seconds
ReturnMaxRowCount Long Number of SQL rows returned (maximum value)
ReturnTotalRowCounts Long Number of SQL rows returned (total value)
ParseMaxRowCount Long Number of SQL rows parsed (maximum value)
ParseTotalRowCounts Long Number of SQL rows parsed (total value)
TotalExecutionCounts Long Execution count (total value)

Fields in tags and fields may change with subsequent updates

fields.message is a string serialized in JSON format

X. Appendix

Refer to the official Alibaba Cloud documentation: