Tencent Cloud PostgreSQL¶
Use the "Cloud Synchronization" series of script packages in the script market to synchronize cloud monitoring and cloud asset data to TrueWatch
Configuration¶
Install Func¶
It is recommended to activate the TrueWatch Integration - Extensions - DataFlux Func (Automata): All prerequisites are automatically installed, please proceed with the script installation.
If you want to deploy Func yourself, refer to Self-deploying Func
Install PostgreSQL Collection Script¶
Note: Please prepare the Tencent Cloud AK in advance (for simplicity, you can directly grant the global read-only permission
ReadOnlyAccess
)
To synchronize PostgreSQL monitoring data, we install the corresponding collection script: "TrueWatch Integration (Tencent Cloud-PostgreSQL Collection)" (ID: integration_tencentcloud_postgresql
)
After clicking 【Install】, enter the corresponding parameters: Tencent Cloud AK, Tencent Cloud account name.
Click 【Deploy Startup Script】, the system will automatically create the Startup
script set and configure the corresponding startup script.
After enabling, you can see the corresponding automatic trigger configuration in 「Manage / Automatic Trigger Configuration」. Click 【Execute】 to execute it immediately without waiting for the scheduled time. After a while, you can check the execution task records and corresponding logs.
If you want to collect corresponding logs, you also need to enable the corresponding log collection script. If you want to collect bills, you need to enable the cloud bill collection script.
Verification¶
- In 「Manage / Automatic Trigger Configuration」, confirm whether the corresponding task has the corresponding automatic trigger configuration, and you can also check the corresponding task records and logs to see if there are any exceptions.
- In TrueWatch, check if there is asset information in 「Infrastructure / Custom」.
- In TrueWatch, check if there is corresponding monitoring data in 「Metrics」.
Metrics¶
After configuring Tencent Cloud-Cloud Monitoring, the default measurement sets are as follows. You can collect more metrics by configuration Tencent Cloud Monitoring Metrics Details
Monitoring Metrics¶
Metric Name | Metric Chinese Name | Description | Unit | Dimensions |
---|---|---|---|---|
Cpu |
CPU Utilization | Actual CPU Utilization | % | resourceId |
DataFileSize |
Data File Size | Data File Occupied Space Size | GB | resourceId |
LogFileSize |
Log File Size | WAL Log File Occupied Space Size | MB | resourceId |
TempFileSize |
Temporary File Size | Temporary File Size | times | resourceId |
StorageRate |
Storage Space Utilization | Total Storage Space Utilization, including temporary files, data files, log files, and other types of database files | % | resourceId |
Qps |
Queries Per Second | Average Number of SQL Statements Executed Per Second | times/second | resourceId |
Connections |
Connections | Total Number of Connections to the Database at the Time of Collection | count | resourceId |
NewConnIn5s |
New Connections in 5 Seconds | All Connections Established in the Last 5 Seconds at the Time of Collection | times | resourceId |
ActiveConns |
Active Connections | Instantaneous Active Connections (Non-idle Connections) at the Time of Collection | count | resourceId |
IdleConns |
Idle Connections | Instantaneous Idle Connections (Idle Connections) at the Time of Collection | count | resourceId |
Waiting |
Waiting Sessions | Number of Sessions Waiting at the Time of Collection (Status: waiting) | times/second | resourceId |
LongWaiting |
Sessions Waiting Over 5 Seconds | Number of Sessions Waiting Over 5 Seconds in a Collection Period (Status: waiting, and waiting state maintained for 5 seconds) | count | resourceId |
IdleInXact |
Idle Transactions | Number of Transactions in Idle State at the Time of Collection | count | resourceId |
LongXact |
Transactions Executing Over 1 Second | Number of Transactions Executing Over 1 Second in a Collection Period | count | resourceId |
Tps |
Transactions Per Second | Average Number of Successful Transactions Per Second (Including Rollbacks and Commits) | times/second | resourceId |
XactCommit |
Committed Transactions | Average Number of Committed Transactions Per Second | times/second | resourceId |
XactRollback |
Rolled Back Transactions | Average Number of Rolled Back Transactions Per Second | times/second | resourceId |
ReadWriteCalls |
Requests | Total Number of Requests in a Statistical Period | times | resourceId |
ReadCalls |
Read Requests | Number of Read Requests in a Statistical Period | times | resourceId |
WriteCalls |
Write Requests | Number of Write Requests in a Statistical Period | times | resourceId |
OtherCalls |
Other Requests | Number of Other Requests in a Statistical Period (begin, create, non-DML, DDL, DQL operations) | times | resourceId |
HitPercent |
Buffer Cache Hit Rate | Hit Rate of All SQL Statements Executed in a Request Period | % | resourceId |
SqlRuntimeAvg |
Average Execution Latency | Average Execution Latency of All SQL Statements in a Statistical Period | ms | resourceId |
SqlRuntimeMax |
Longest TOP10 Execution Latency | Average Execution Latency of Longest TOP10 SQL Statements in a Statistical Period | ms | resourceId |
SqlRuntimeMin |
Shortest TOP10 Execution Latency | Average Execution Latency of Shortest TOP10 SQL Statements in a Statistical Period | ms | resourceId |
SlowQueryCnt |
Slow Query Count | Number of Slow Queries in a Collection Period | count | resourceId |
LongQuery |
SQL Statements Executing Over 1 Second | Number of SQL Statements Executing Over 1s at the Time of Collection | count | resourceId |
2pc |
2pc Transactions | Number of 2PC Transactions at the Time of Collection | count | resourceId |
Long2pc |
2pc Transactions Uncommitted Over 5s | Number of 2PC Transactions Executing Over 5s at the Time of Collection | count | resourceId |
Deadlocks |
Deadlocks | Total Number of Deadlocks in a Collection Period | count | resourceId |
Memory |
Memory Usage | Memory Used | MB | resourceId |
MemoryRate |
Memory Utilization | Percentage of Memory Used to Total Memory | % | resourceId |
Objects¶
The collected Tencent Cloud postgresql object data structure can be seen in 「Infrastructure-Custom」.
{
"measurement": "tencentcloud_postgresql",
"tags": {
"ClusterType" : "0",
"InstanceId" : "cmxxxx",
"InstanceName": "test_01",
"InstanceType": "1",
"MongoVersion": "MONxxxx",
"NetType" : "1",
"PayMode" : "0",
"ProjectId" : "0",
"RegionId" : "ap-nanjing",
"Status" : "2",
"VpcId" : "vpc-nf6xxxxx",
"Zone" : "ap-nanjing-1",
"name" : "cmxxxx"
},
"fields": {
"CloneInstances" : "[]",
"CreateTime" : "2022-08-24 13:54:00",
"DeadLine" : "2072-08-24 13:54:00",
"ReadonlyInstances": "[]",
"RelatedInstance" : "{Instance JSON Data}",
"ReplicaSets" : "{Instance JSON Data}",
"StandbyInstances" : "[]",
"message" : "{Instance JSON Data}",
}
}
Logging¶
Slow Query Statistics¶
Prerequisites¶
Note 1: The code execution of this script depends on the PostgreSQL instance object collection. If the custom object collection of PostgreSQL is not configured, the slow log script cannot collect slow log data.
Install Log Collection Script¶
On the previous basis, you need to install a corresponding PostgreSQL Slow Query Statistics Log Collection Script
In 「Manage / Script Market」, click and install the corresponding script package:
- "TrueWatch Integration (Tencent Cloud-PostgreSQL Slow Query Log Collection)" (ID:
integration_tencentcloud_postgresql_slowlog
)
After the data is synchronized normally, you can view the data in TrueWatch's 「Logs」.
The reported data example is as follows:
{
"measurement": "tencentcloud_postgre_slowlog",
"tags": {
"AppId": "137185",
"ClientAddr": "",
"DBCharset": "UTF8",
"DBEngine": "postgresql",
"DBEngineConfig": "",
"DBInstanceClass": "cdb.pg.ts1.2g",
"DBInstanceId": "postgres-3coh1xgm",
"DBInstanceName": "Unnamed",
"DBInstanceStatus": "running",
"DBInstanceType": "primary",
"DBInstanceVersion": "standard",
"DBVersion": "10.17",
"DatabaseName": "postgres",
"PayType": "postpaid",
"ProjectId": "0",
"Region": "ap-shanghai",
"RegionId": "ap-shanghai",
"SubnetId": "subnet-bp2jqhcj",
"Type": "TS85",
"Uid": "4147",
"UserName": "postgres",
"VpcId": "vpc-kcpy",
"Zone": "ap-shanghai-2",
"name": "postgres-3coh1xgm"
},
"fields": {
"NormalQuery": "select $1 from information_schema.tables where table_schema = $2 and table_name = $3",
"AvgCostTime" : "101.013005",
"CostTime" : "101.013025",
"FirstTime" : "2021-07-27 03:12:01",
"LastTime" : "2021-07-27 03:12:01",
"MaxCostTime" : "101.828125",
"MinCostTime" : "101.828125",
"message" : "{Slow Query JSON Data}"
}
}
Note: The fields in
tags
andfields
may change with subsequent updates. Note 1:tags
values are supplemented by custom objects. Note 2:fields.message
is a JSON serialized string.
Appendix¶
TencentCloud-PostgreSQL 「Regions」¶
Please refer to Tencent official documentation:
TencentCloud-PostgreSQL 「Slow Log Information Documentation」¶
Please refer to Tencent official documentation: