Feature Background
In certain common scenarios, customer applications need not only the overall monitoring information of the database instance, but also need to use the process monitoring information in the instance to judge the business health, and then make business logic decisions. Typically, in SaaS scenarios, a single tenant of the user uses a database of the database instance alone. By monitoring the resource usage of the processes connected to the database, the business party can further judge the current health of the tenant and other situations.
Description of the Feature
TencentDB for PostgreSQL provides process monitoring information for the database instance. The system provides a view named tencentdb_process_system_usage, which contains the following information, as explained below:
|
pid | Process Number. |
username | Username. |
datname | Database Name. |
backend_type | Process type. Possible types include autovacuum launcher, autovacuum worker, logical replication launcher, logical replication worker, parallel worker, background writer, client backend, checkpointer, startup, walreceiver, walsender, and walwriter. In addition, backend Workers registered by extensions may have additional types. |
query | Refers to the query statement that is being executed currently. |
cpu_usage | Refers to the CPU utilization during the current query sampling period. For the sampling interval, the parameter tencentdb_system_stat.sampling_interval is provided for settings. The unit of this parameter is milliseconds and the default value is 1000. |
memory_bytes | Refers to the memory usage rate during the current sampling period, in bytes. |
Use Instructions
1. Create a new extension with the following command:
postgres => create extension tencentdb_system_stat;
CREATE EXTENSION
postgres =>
2. The usage of the tencentdb_process_system_usage view is the same as other views. You only need to log in to the PostgreSQL database instance and perform a query. Here is an example statement:
select * from tencentdb_process_system_usage;
Was this page helpful?