Skip to content

Configuration Manual for the "Huawei Cloud - RDS Slow Log Details 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 RDS instance object collection. If RDS 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:

Configuration One (Recommended)

Field Type Required Description
regions list Required List of regions to be collected
regions[#] str Required Region ID. For example: 'cn-north-4'
See appendix for full list

The collector will automatically retrieve all IAM projects under the region and then obtain resources based on IAM projects

Configuration Two (Legacy Compatibility)

Field Type Required Description
region_projects dict Required List of 'Region - Project ID' pairs to be collected
region_projects[#] str:list Required Key-value pairs where:
Key represents the region (for example: 'cn-north-4')
Value represents the list of project IDs to be collected under that region
See appendix for full list

2. Configuration Example

Specifying a Region

Collect RDS slow log data for projects in the cn-north-4 region.

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

3. Data Reporting Format

After data synchronization, 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
{
  "measurement": "huaweicloud_rds_slowlog_detail",
  "tags": {
    "RegionId"               : "cn-north-4",
    "project_id"             : "c631f046252dxxxxxxxf253c62d48585",
    "enterprise_project_id"  : "0",
    "instance_id"            : "1d0c91561f4644dxxxxxxd68304b0520din01",
    "instance_name"          : "rds-df54-xxxx",
    "status"                 : "ACTIVE",
    "type"                   : "Single",
    "engine"                 : "MySQL",
    "database"               : "xxx_test",
    "type"                   : "SELECT",
    "users"                  : "root"
  },
  "fields": {
    "client_ip"              : "100.*.*.68",
    "count"                  : "1",
    "execution_time"         : "0.000146 s",
    "lock_time"              : "0.000072",
    "rows_examined"          : "2",
    "rows_sent"              : "0",
    "start_time"             : "2023-07-11T07:08:59",
    "query_sample"           : "SELECT sleep(N) LIMIT N, N;",
    "message"                : "{Instance JSON data}"
  }
}

Partial parameter descriptions are as follows:

Field Type Description
count str Number of SQL executions.
execution_time str Execution time.
start_time str Execution timestamp (UTC).
lock_time str Lock wait time (only supported by MySQL).
rows_sent integer Result count statistics (only supported by MySQL).
rows_examined integer Number of rows scanned (only supported by MySQL).

4. Precautions

Fields in tags and fields may change with subsequent updates

fields.message is a JSON serialized string

5. Troubleshooting

When running the program, the following errors may occur:

Text Only
1
2
API call error:
[ClientRequestException]{status_code:404,request_id:a8bf4ee50523dab10e631e51aed70196,error_code:None,error_msg:{"errCode":"DBS.280110","externalMessage":"Selected DB instance does not exist."} }

The error message will print details about the corresponding instance, such as:

Text Only
1
Instance information: {'region_id': 'xxx', 'project_id': 'xxx', 'instance_id': 'xxx'}

Reason: The slow log data for a specific RDS instance was requested, but the instance has already been released, causing the API to throw an error.

Solution: Ignore the error.

X. Appendix

HuaweiCloud-RDS "Regions"

Refer to the official HuaweiCloud documentation:

HuaweiCloud-RDS "Slow Log Information Documentation"

Refer to the official HuaweiCloud documentation: