Skip to content

Alibaba Cloud RDS PostgreSQL

Alibaba Cloud RDS PostgreSQL Metrics Display, including CPU usage, memory usage, etc.

Configuration

Install Func

It is recommended to activate TrueWatch Integration - Extensions - DataFlux Func (Automata)

For self-deployment of Func, refer to Self-deploy Func

Activate Script

Note: Please prepare an Alibaba Cloud AK with the required permissions in advance (for simplicity, you can directly grant the global read-only permission ReadOnlyAccess)

Activate Script for Automata

  1. Log in to the TrueWatch console
  2. Click the 【Integration】 menu and select 【Cloud Account Management】
  3. 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
  4. Click 【Test】, if the test is successful, click 【Save】. If the test fails, please check if the relevant configuration information is correct and retest
  5. Click 【Cloud Account Management】 list to see the added cloud account, click the corresponding cloud account to enter the details page
  6. Click the 【Integration】 button on the cloud account details page, find Alibaba Cloud RDS PostgreSQL under the Not Installed list, click the 【Install】 button, and the installation interface will pop up for installation.

Manual Activation Script

  1. Log in to the Func console, click 【Script Market】, enter the TrueWatch script market, search: integration_alibabacloud_rds

  2. Click 【Install】, then enter the corresponding parameters: Alibaba Cloud AK ID, AK Secret, and account name.

  3. Click 【Deploy Startup Script】, the system will automatically create the Startup script set and automatically configure the corresponding startup script.

  4. After enabling, you can see the corresponding automatic trigger configuration in 「Manage / Automatic Trigger Configuration」. Click 【Execute】 to execute once immediately without waiting for the scheduled time. After a while, you can check the execution task records and corresponding logs.

Verification

  1. In 「Manage / Automatic Trigger Configuration」, confirm whether the corresponding task has the corresponding automatic trigger configuration, and check the corresponding task records and logs to see if there are any exceptions
  2. In TrueWatch, check if there is asset information in 「Infrastructure / Custom」
  3. In TrueWatch, check if there is corresponding monitoring data in 「Metrics」

Metrics

After configuring Alibaba Cloud Cloud Monitor, the default Measurement is as follows. More Metrics can be collected through configuration Alibaba Cloud Cloud Monitor Metrics Details

Metric Name Description Unit Dimension
PG_DBAge PG_Database Age count instanceId
PG_InactiveSlots PG_Inactive Replication Slots 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 Seconds 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 Seconds 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 Statistics

Prerequisites for Slow Query Statistics

Note 1: The code execution of this script depends on the RDS instance object collection. If the custom object collection of RDS is not configured, the slow log script cannot collect slow log data Note 2: Due to the 6~8 hours delay in Alibaba Cloud statistical data return, the collector update data may be delayed. For details, refer to Alibaba Cloud documentation: Cloud Database RDS Query Slow Log Statistics Note 3: This collector supports all versions of MySQL (except MySQL 5.7 Basic Edition), SQL Server 2008 R2, and MariaDB 10.3 type databases

Slow Query Statistics Installation Script

On the previous basis, you need to install a corresponding RDS Slow Query Statistics Log Collection Script

In 「Manage / Script Market」, click and install the corresponding script package:

  • 「TrueWatch Integration (Alibaba Cloud - RDS Slow Query Statistics Log Collection)」(ID: integration_alibabacloud_rds_slowlog)

After the data is synchronized normally, you can view the data in TrueWatch's 「Logs」.

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"
  },
  "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"                      : "{Log JSON Data}"
  }
}

Some parameter descriptions are as follows:

Field Type Description
SQLServerTotalExecutionTimes int SQL Server Execution Duration (Total, milliseconds)
AvgExecutionTime int Execution Time (Average) Unit: seconds
SQLServerAvgExecutionTime int Execution Time (Average) Unit: seconds
MySQLTotalExecutionTimes int MySQL Execution Time (Total) Unit: seconds
SQLServerTotalExecutionTimes int SQL Server Execution Time (Total) Unit: milliseconds
SQLServerTotalExecutionCounts int SQL Server Execution Count (Total)
MySQLTotalExecutionCounts int MySQL Execution Count (Total)

Note: AvgExecutionTime, SQLServerAvgExecutionTime, SQLServerTotalExecutionTimes, and other fields are only supported by SQL Server instances Note: Fields in tags, fields 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 the custom object collection of 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 a corresponding RDS Slow Query Details Log Collection Script

In 「Manage / Script Market」, click and install the corresponding script package:

  • 「TrueWatch 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 TrueWatch's 「Logs」.

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}"
  }
}

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 Return Row Count
ParseRowCounts int Parse Row Count
ExecutionStartTime str Execution Start Time
CpuTime int CPU Processing Duration
RowsAffectedCount int Affected Row Count
LastRowsAffectedCount int Last Statement Affected Row Count

Note: CpuTime, RowsAffectedCount, LastRowsAffectedCount and other fields are only supported by SQL Server instances Note: Fields in tags, fields may change with subsequent updates Note: fields.message is a JSON serialized string