Tencent Cloud PostgreSQL¶
Use the "Cloud Sync" series of script packages in the script market to synchronize cloud monitoring and cloud asset data to Guance
Configuration¶
Install Func¶
It is recommended to activate the Guance integration - extension - hosted Func: all preconditions are automatically installed, please proceed with the script installation.
If deploying Func manually, refer to Manual Func Deployment
Activate Script¶
Note: Please prepare a Tencent Cloud AK with the required permissions in advance (for simplicity, you can directly grant the global read-only permission
ReadOnlyAccess).
Activate Script for Hosted Version¶
- Log in to the Guance console.
- Click the 【Integration】 menu, select 【Cloud Account Management】.
- Click 【Add Cloud Account】, select 【Tencent Cloud】, and fill in the required information on the interface. If you have already configured the cloud account information, ignore this step.
- Click 【Test】, and after a successful test, click 【Save】. If the test fails, please check if the relevant configuration information is correct and test again.
- Click 【Cloud Account Management】, and 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, find
Tencent Cloud PostgreSQLunder theNot Installedlist, and click the 【Install】 button to pop up the installation interface and install.
Activate Script Manually¶
-
Log in to the Func console, click 【Script Market】, enter the Guance script market, and search for
integration_tencentcloud_postgresql. -
Click 【Install】, then enter the corresponding parameters: Tencent Cloud AK, SK, and account name.
-
Click 【Deploy Startup Script】, the system will automatically create the
Startupscript set and configure the corresponding startup script. -
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. After a short wait, 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, and check the corresponding task records and logs to see if there are any exceptions.
- In Guance, check if the asset information exists in 「Infrastructure / Custom」.
- In Guance, check if there is corresponding monitoring data in 「Metrics」.
Metrics¶
After configuring Tencent Cloud Cloud Monitoring, the default measurement is as follows. More metrics can be collected through configuration Tencent Cloud Cloud Monitoring Metrics Details
Monitoring Metrics¶
| Metric Name | Metric Chinese Name | Meaning | Unit | Dimensions |
|---|---|---|---|---|
Cpu |
CPU Utilization | Actual CPU Utilization | % | resourceId |
DataFileSize |
Data File Size | Size of data file occupied space | GB | resourceId |
LogFileSize |
Log File Size | Size of wal log file occupied space | MB | resourceId |
TempFileSize |
Temporary File Size | Size of temporary file | 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/sec | 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) to the database at the time of collection | count | resourceId |
IdleConns |
Idle Connections | Instantaneous idle connections (idle connections) to the database at the time of collection | count | resourceId |
Waiting |
Waiting Sessions | Number of sessions waiting in the database at the time of collection (state is waiting) | times/sec | resourceId |
LongWaiting |
Sessions Waiting Over 5 Seconds | Number of sessions waiting over 5 seconds in a collection period (state is waiting, and waiting state has been maintained for 5 seconds) | count | resourceId |
IdleInXact |
Idle Transactions | Number of transactions in idle state in the database at the time of collection | count | resourceId |
LongXact |
Transactions Over 1 Second | Number of transactions with execution time over 1 second in a collection period | count | resourceId |
Tps |
Transactions Per Second | Average number of successful transactions executed per second (including rollbacks and commits) | times/sec | resourceId |
XactCommit |
Committed Transactions | Average number of committed transactions per second | times/sec | resourceId |
XactRollback |
Rolled Back Transactions | Average number of rolled back transactions per second | times/sec | 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 the longest TOP10 SQL statements in a statistical period | ms | resourceId |
SqlRuntimeMin |
Shortest TOP10 Execution Latency | Average execution latency of the 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 Queries Over 1 Second | Number of SQL queries with execution time 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 Over 5 Seconds | Number of 2PC transactions with execution time over 5s at the time of collection | count | resourceId |
Deadlocks |
Deadlocks | Total number of deadlocks in a collection period | count | resourceId |
Memory |
Memory Usage | Amount of 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}",
}
}
Logs¶
Slow Query Statistics¶
Prerequisites¶
Note 1: The code execution of this script depends on the PostgreSQL instance object collection. If the custom object collection for 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 another script package corresponding to PostgreSQL slow query statistics log collection.
In 「Management / Script Market」, click and install the corresponding script package:
- 「Guance 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 the 「Logs」 of Guance.
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
tagsandfieldsmay change with subsequent updates. Note 1: Thetagsvalues are supplemented by custom objects. Note 2:fields.messageis a JSON serialized string.
Appendix¶
TencentCloud-PostgreSQL 「Region」¶
Please refer to the Tencent official documentation:
TencentCloud-PostgreSQL 「Slow Log Information Documentation」¶
Please refer to the Tencent official documentation: