Skip to content

Collector "Alibaba Cloud - PolarDB Slow Query Log" 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 PolarDB instance object collection. If the custom object collection for PolarDB 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 be collected
regions[#] str Required Region ID. For example: 'cn-hangzhou'
See appendix for the complete list

2. Configuration Example

Specified Region

Collect data from the Hangzhou region

collector_configs = {
    'regions': [ 'cn-hangzhou' ]
}

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_polardb_slowlog_record",
  "tags": {
    "DBName"     : "PolarDB_MySQL",
    "DBNodeId"   : "pi-***************",
    "HostAddress": "testdb[testdb] @ [100.**.**.242]"
  },
  "fields": {
    "SQLText"           : "select id,name from tb_table",
    "ExecutionStartTime": "2021-04-07T03:47Z",
    "QueryTimes"        : 20,
    "ReturnRowCounts"   : 0,
    "ParseRowCounts"    : 0,
    "LockTimes"         : 0,
    "QueryTimeMS"       : 100,
    "message"           : "{Log JSON Data}"
  }
}

Partial parameter descriptions are as follows:

Field Type Description
QueryTimes Long SQL execution duration, in seconds
QueryTimesMS Long Query time. In milliseconds
ReturnRowCounts Long Number of rows returned
ParseRowCounts Long Number of rows parsed
ExecutionStartTime String Time when SQL execution started. Format: YYYY-MM-DDThh:mmZ (UTC time)
LockTimes Long SQL lock duration, in seconds
Note

The 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: