Skip to content

Tencent Cloud PostgreSQL

Use the "Guance Cloud Sync" series of script packages in the script market to synchronize data from cloud monitoring and cloud assets to Guance

Configuration

Install Func

It is recommended to activate Guance Integration - Extensions - DataFlux Func (Automata): All prerequisites are automatically installed. Please proceed with script installation.

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

Activate Script

Note: Please prepare a Tencent 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)

  1. Log in to the Guance console.
  2. Click the [Integration] menu, select [Cloud Account Management].
  3. Click [Add Cloud Account], select [Tencent 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]. After a successful test, click [Save]. If the test fails, please check if the relevant configuration information is correct and test again.
  5. Click [Cloud Account Management]. You can see the added cloud account in the list. Click the corresponding cloud account to enter the details page.
  6. Click the [Integration] button on the cloud account details page. Under the Not Installed list, find Tencent Cloud PostgreSQL, click the [Install] button, and install it in the pop-up installation interface.

Manually Activate Script

  1. Log in to the Func console, click [Script Market], enter the Guance script market, and search for integration_tencentcloud_postgresql.

  2. After clicking [Install], enter the corresponding parameters: Tencent Cloud AK, SK, and account name.

  3. Click [Deploy Startup Script]. The system will automatically create a Startup script set and automatically configure the corresponding startup scripts.

  4. 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, and you can view the execution task records and corresponding logs.

Verification

  1. In [Management / Automatic Trigger Configuration], confirm whether the corresponding task has the corresponding automatic trigger configuration. You can also view the corresponding task records and logs to check for any exceptions.
  2. In Guance, check [Infrastructure / Custom] to see if asset information exists.
  3. In Guance, check [Metrics] to see if there is corresponding monitoring data.

Metrics

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

Monitoring Metrics

Metric English Name Metric Chinese Name Meaning Unit Dimensions
Cpu CPU Utilization Actual CPU utilization % resourceId
DataFileSize Data File Size Space occupied by data files GB resourceId
LogFileSize Log File Size Space occupied by wal log files MB resourceId
TempFileSize Temporary File Size Size of temporary files times resourceId
StorageRate Storage Space Usage Rate Total storage space usage rate, 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 current connections to the database when collection is initiated count resourceId
NewConnIn5s New Connections in 5 Seconds All connections established in the last 5 seconds when querying during database collection initiation times resourceId
ActiveConns Active Connections Instantaneous active connections (non-idle connections) in the database when collection is initiated count resourceId
IdleConns Idle Connections Instantaneous idle connections (idle connections) in the database when querying during collection initiation count resourceId
Waiting Waiting Sessions Number of sessions waiting in the database when collection is initiated (status is waiting) times/second resourceId
LongWaiting Sessions Waiting Over 5 Seconds Number of sessions waiting for more than 5 seconds in a collection cycle (status is waiting, and the waiting state has been maintained for 5 seconds) count resourceId
IdleInXact Idle Transactions Number of transactions in idle state in the database when collection is initiated count resourceId
LongXact Transactions Executing Over 1 Second Number of transactions with execution time exceeding 1 second in a collection cycle count resourceId
Tps Transactions Per Second Average number of successful transactions executed 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 cycle times resourceId
ReadCalls Read Requests Number of read requests in a statistical cycle times resourceId
WriteCalls Write Requests Number of write requests in a statistical cycle times resourceId
OtherCalls Other Requests Number of other requests in a statistical cycle (begin, create, non-DML, DDL, DQL operations) times resourceId
HitPercent Buffer Cache Hit Rate Hit rate of all SQL statements executed in a request cycle % resourceId
SqlRuntimeAvg Average Execution Latency Average execution latency of all SQL statements in a statistical cycle ms resourceId
SqlRuntimeMax Top 10 Longest Execution Latencies Average execution latency of the top 10 longest SQL statements in a statistical cycle ms resourceId
SqlRuntimeMin Top 10 Shortest Execution Latencies Average execution latency of the top 10 shortest SQL statements in a statistical cycle ms resourceId
SlowQueryCnt Slow Query Count Number of slow queries occurring in a collection cycle count resourceId
LongQuery SQL Queries Executing Over 1 Second Number of SQL queries with execution time exceeding 1s when querying during database collection initiation count resourceId
2pc 2PC Transactions Current number of 2PC transactions when database collection is initiated count resourceId
Long2pc 2PC Transactions Uncommitted Over 5s Current number of 2PC transactions with execution time exceeding 5s when database collection is initiated count resourceId
Deadlocks Deadlocks Total number of deadlocks in a collection cycle count resourceId
Memory Memory Usage Amount of memory used MB resourceId
MemoryRate Memory Usage Rate Percentage of total memory used % resourceId

Object

Collected Tencent Cloud postgresql object data structure can be viewed from [Infrastructure / Resource Catalog] in the dataset tencentcloud_postgres.

Logging

Slow Query Records

Prerequisites

Note 1: The code operation 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 top of the previous setup, you need to install a corresponding PostgreSQL Slow Query Log Collection script.

In [Management / Script Market], click and install the corresponding script package:

  • Integration (TencentCloud-PostgreSQL Slowlog Record Collector), Script Set ID integration_tencentcloud_postgresql_slowlog_record

After 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_record",
  "tags": {
      "AppId": "137185",
      "DBEngine": "postgresql",
      "DBInstanceId": "postgres-3coh1xgm",
      "DBInstanceName": "Unnamed",
      "DBInstanceType": "primary",
      "DatabaseName": "postgres",
      "ProjectId": "0",
      "RegionId": "ap-shanghai",
      "Zone": "ap-shanghai-2",
      "UserName": "postgres"
  },
  "fields": {
      "ClientAddr": "[local]",
      "Duration": 101.013,
      "RawQuery": "select 1 from information_schema.tables where table_schema = 'xxx' and table_name = 'xxx'",
      "SessionStartTime": "2021-07-27 03:12:01 CST",
      "message"     : "{Slow query JSON data}"
  }
}

Note: The fields in tags and fields 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 the official Tencent documentation:

TencentCloud-PostgreSQL 「Slow Log Information Documentation」

Please refer to the official Tencent documentation:

Feedback

Is this page helpful? ×