Alibaba Cloud RDS PostgreSQL¶
Alibaba Cloud RDS PostgreSQL Metrics display, including CPU usage, memory usage, etc.
Configuration¶
Install Func¶
It is recommended to activate the Guance Integration - Extensions - DataFlux Func (Automata)
For self-deploying Func, refer to Self-deploy Func
Activate Script¶
Note: Please prepare the Alibaba Cloud AK that meets the requirements in advance (for simplicity, you can directly grant the global read-only permission
ReadOnlyAccess)
Activate Script on DataFlux Func (Automata)¶
- Log in to the Guance console.
- Click the [Integration] menu, select [Cloud Account Management].
- Click [Add Cloud Account], select [Alibaba Cloud], and fill in the required information on the interface. If the cloud account information has been configured before, ignore this step.
- Click [Test]. After the test is successful, click [Save]. If the test fails, please check whether the relevant configuration information is correct and test again.
- Click [Cloud Account Management]. You can see the added cloud account in the list. Click the corresponding cloud account to enter the details page.
- Click the [Integration] button on the cloud account details page. Under the
Not Installedlist, findAlibaba Cloud RDS PostgreSQL, click the [Install] button, and install it in the pop-up installation interface.
Activate Script Manually¶
- Log in to the Func console, click [Script Market], enter the Guance Script Market, and search for:
integration_alibabacloud_rds. - After clicking [Install], enter the corresponding parameters: Alibaba Cloud AK ID, AK Secret, and account name.
- Click [Deploy Startup Script]. The system will automatically create the
Startupscript set and automatically configure the corresponding startup script. - After activation, you can see the corresponding automatic trigger configuration in "Management / Automatic Trigger Configuration". Click [Execute] to execute it immediately once without waiting for the scheduled time. Wait a moment, you can view the execution task records and corresponding logs.
Verification¶
- In "Management / Automatic Trigger Configuration", confirm whether the corresponding task has the corresponding automatic trigger configuration. You can also check the corresponding task records and logs to see if there are any exceptions.
- In Guance, check if asset information exists in "Infrastructure / Custom".
- In Guance, check in "Metrics" to see if there is corresponding monitoring data.
Metrics¶
After configuring Alibaba Cloud CloudMonitor, the default Measurement is as follows. More Metrics can be collected through configuration. Alibaba Cloud CloudMonitor Metric Details
| Metric Name | Description | Unit | Dimension |
|---|---|---|---|
| PG_DBAge | PG_Database age | count | instanceId |
| PG_InactiveSlots | PG_Inactive replication slot count | count | instanceId |
| PG_MaxExecutingSQLTime | PG_Slowest SQL execution time | seconds | instanceId |
| PG_MaxSlotWalDelay | PG_Max replication slot delay (MB) | byte | instanceId |
| PG_ReplayLatency | PG_Slowest Standby replay delay (MB) | byte | instanceId |
| PG_SwellTime | PG_Longest transaction execution time | seconds | instanceId |
| active_connections_per_cpu | PG_Average active connections per CPU | count | instanceId |
| conn_usgae | PG_Connection usage rate | % | instanceId |
| cpu_usage | PG_CPU usage rate | % | instanceId |
| five_seconds_executing_sqls | PG_Five-second slow SQL | count | instanceId |
| iops_usage | PG_IOPS usage rate | % | instanceId |
| local_fs_inode_usage | PG_INODE usage rate | % | instanceId |
| local_fs_size_usage | PG_Disk space usage rate | % | instanceId |
| local_pg_wal_dir_size | PG_WAL file size | MB | instanceId |
| mem_usage | PG_Memory usage rate | % | instanceId |
| one_second_executing_sqls | PG_One-second slow SQL | count | instanceId |
| three_seconds_executing_sqls | PG_Three-second slow SQL | count | instanceId |
Object¶
The collected Alibaba Cloud RDS PostgreSQL object data structure can be seen in "Infrastructure - Custom"
{
"measurement": "aliyun_rds",
"tags": {
"name" : "rm-xxxxx",
"DBInstanceType" : "Primary",
"PayType" : "Prepaid",
"Engine" : "MySQL",
"DBInstanceClass" : "rds.mysql.s2.large",
"DBInstanceId" : "rm-xxxxx",
"ZoneId" : "cn-shanghai-h",
"RegionId" : "cn-shanghai",
"DBInstanceDescription": "Business system",
"LockMode" : "Unlock",
"Category" : "Basic",
"ConnectionMode" : "Standard",
"DBInstanceNetType" : "Intranet",
"DBInstanceStorageType": "local_ssd",
},
"fields": {
"CreationTime" : "2022-12-13T16:00:00Z",
"ExpireTime" : "2022-12-13T16:00:00Z",
"DiskUsed" : "10000",
"BackupSize" : "10000",
"LogSize" : "10000",
"BackupLogSize" : "10000",
"BackupDataSize" : "10000",
"ConnectionString" : "{Connection address JSON data}",
"DBInstanceStorage": "100",
"accounts" : "{User permission information JSON data}",
"databases" : "{Database information JSON data}",
"SSLExpireTime" : "2022-10-11T08:16:43Z",
"message" : "{Instance JSON data}",
}
}
Logging¶
Slow Query Details¶
Slow Query Details Prerequisites¶
Note: The code operation 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.
Slow Query Details Installation Script¶
On the previous basis, you need to install another script package for RDS slow query details log collection.
In "Management / Script Market", click and install the corresponding script package:
- "Guance Integration (Alibaba Cloud-RDS Slow Query Details Log Collection)" (ID:
integration_alibabacloud_rds_slowlog_record)
After the data is synchronized normally, you can view the data in the "Log" of Guance.
The reported data example 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}"
}
}
Partial 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 row count |
ParseRowCounts |
int | Parsed row count |
ExecutionStartTime |
str | Execution start time |
CpuTime |
int | CPU processing time |
RowsAffectedCount |
int | Affected row count |
LastRowsAffectedCount |
int | Last statement affected row count |
Note: Fields such as
CpuTime,RowsAffectedCount,LastRowsAffectedCountare only supported by SQL Server instances. Note: Fields intagsandfieldsmay change with subsequent updates. Note:fields.messageis a JSON serialized string.