Alibaba Cloud RDS PostgreSQL¶
Alibaba Cloud RDS PostgreSQL metrics display, including CPU usage, memory usage, etc.
Configuration¶
Install Func¶
It is recommended to enable Guance integration - extension - hosted Func
If you deploy Func by yourself, refer to Self-deployed Func
Enable Script¶
Note: Please prepare the required Alibaba Cloud AK in advance (for simplicity, you can directly grant global read-only permission
ReadOnlyAccess
)
Hosted Version Enable Script¶
- Log in to Guance console
- Click on the [Integration] menu, select [Cloud Account Management]
- Click [Add Cloud Account], choose [Alibaba Cloud], fill in the required information on the interface. If cloud account information has been configured before, ignore this step.
- Click [Test], after a successful test click [Save]. If the test fails, check whether the related configuration information is correct and retest.
- In the [Cloud Account Management] list, you can see the added cloud accounts. Click the corresponding cloud account to enter the details page.
- Click the [Integration] button on the cloud account details page. In the
Not Installed
list, findAlibaba Cloud RDS PostgreSQL
, click the [Install] button, and install it via the pop-up installation interface.
Manual Enable Script¶
-
Log in to the Func console, click [Script Market], enter the official script market, search for
guance_aliyun_rds
-
After clicking [Install], input the corresponding parameters: Alibaba Cloud AK ID, AK Secret, and account name.
-
Click [Deploy Start Script], the system will automatically create a
Startup
script set and automatically configure the corresponding start scripts. -
After enabling, you can see the corresponding automatic trigger configuration in "Management / Automatic Trigger Configuration". Click [Execute] to immediately execute once without waiting for the scheduled time. Wait for a moment, and you can view the execution task records and corresponding logs.
We default collect some configurations, for more details see the metrics section Customize Cloud Object Metrics
Verification¶
- In "Management / Automatic Trigger Configuration", confirm whether the corresponding tasks have the corresponding automatic trigger configuration, and at the same time, you can check the corresponding task records and logs to see if there are any abnormalities.
- In Guance, under "Infrastructure / Custom", check if there are asset information.
- In Guance, under "Metrics", check if there are corresponding monitoring data.
Metrics¶
After configuring Alibaba Cloud - Cloud Monitoring, the default metric set is as follows. You can collect more metrics through configuration Alibaba Cloud Cloud Monitoring 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 duration | 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 duration | 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 SQLs | 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 SQLs | count | instanceId |
three_seconds_executing_sqls | PG_three-second slow SQLs | count | instanceId |
Objects¶
The collected Alibaba Cloud RDS PostgreSQL object data structure can be seen from "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" : "{JSON connection address data}",
"DBInstanceStorage": "100",
"accounts" : "{JSON user privilege data}",
"databases" : "{JSON database data}",
"SSLExpireTime" : "2022-10-11T08:16:43Z",
"message" : "{JSON instance data}",
}
}
Logs¶
Slow Query Statistics¶
Prerequisites for Slow Query Statistics¶
Note 1: The code execution of this script depends on the RDS instance object collection. If RDS custom object collection is not configured, the slow log script cannot collect slow log data. Note 2: Due to the 6~8 hours delay in returning statistics data from Alibaba Cloud, the collector's update might also have a delay. For detailed reference, see Alibaba Cloud documentation: Cloud Database RDS Slow Log Statistics Query. Note 3: This collector supports all versions of MySQL (excluding the basic version of MySQL 5.7), SQL Server 2008 R2, MariaDB 10.3 type databases. To collect other types of databases, use the Alibaba Cloud-RDS Slow Query Detail collector.
Slow Query Statistics Installation Script¶
Based on the previous setup, you need to install another script corresponding to RDS Slow Query Statistics Log Collection.
In "Management / Script Market," click and install the corresponding script package:
- "Guance Integration (Alibaba Cloud - RDS Slow Query Statistics Log Collection)" (ID:
guance_aliyun_rds_slowlog
)
After data synchronization, you can view the data in the "Logs" section of Guance.
An example of the reported data 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"
},
"fields": {
"SQLHASH" : "436f9dd030e0a87920bbcd818b34f271",
"SQLText" : "{SQL statement}",
"CreateTime" : "2022-06-05Z",
"SQLServerTotalExecutionTimes" : 0,
"MaxExecutionTime" : 1,
"MaxLockTime" : 0,
"AvgExecutionTime" : 0,
"MySQLTotalExecutionTimes" : 0,
"SQLServerTotalExecutionTimes" : 1,
"SQLServerTotalExecutionCounts": 0,
"MySQLTotalExecutionCounts" : 0,
"SQLServerAvgExecutionTime" : 0,
"message" : "{JSON log data}"
}
}
Some parameter descriptions are as follows:
Field | Type | Description |
---|---|---|
SQLServerTotalExecutionTimes |
int | SQL Server execution duration (total value, milliseconds) |
AvgExecutionTime |
int | Execution time (average value) unit: seconds |
SQLServerAvgExecutionTime |
int | Execution time (average value) unit: seconds |
MySQLTotalExecutionTimes |
int | MySQL execution time (total value) unit: seconds |
SQLServerTotalExecutionTimes |
int | SQL Server execution time (total value) unit: milliseconds |
SQLServerTotalExecutionCounts |
int | SQL Server execution count (total value) |
MySQLTotalExecutionCounts |
int | MySQL execution count (total value) |
Note: Fields such as
AvgExecutionTime
,SQLServerAvgExecutionTime
,SQLServerTotalExecutionTimes
, etc., are supported only by SQL Server instances. Note: Fields intags
andfields
may change with subsequent updates.
Slow Query Details¶
Prerequisites for Slow Query Details¶
Note: The code execution of this script depends on the RDS instance object collection. If RDS custom object collection is not configured, the slow log script cannot collect slow log data.
Slow Query Details Installation Script¶
Based on the previous setup, you need to install another script corresponding to 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:
guance_aliyun_rds_slowlog_record
)
After data synchronization, you can view the data in the "Logs" section of Guance.
Configure Cloud Database RDS Slow Query Details
An example of the reported data 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" : "{JSON log data}"
}
}
Some parameter descriptions 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 | Execution start time |
CpuTime |
int | CPU processing duration |
RowsAffectedCount |
int | Number of affected rows |
LastRowsAffectedCount |
int | Number of affected rows of the last statement |
Note: Fields such as
CpuTime
,RowsAffectedCount
,LastRowsAffectedCount
, etc., are supported only by SQL Server instances. Note: Fields intags
andfields
may change with subsequent updates. Note:fields.message
is a JSON serialized string.