Project: SkyWalking (Observability and Analysis / Observability)
File: backend-postgresql-monitoring.md

SkyWalking leverages postgres-exporter for collecting metrics data from PostgreSQL. It leverages OpenTelemetry Collector to transfer the metrics to and into the . postgres-exporter collect metrics data from PostgreSQL. OpenTelemetry Collector fetches metrics from postgres-exporter via Prometheus Receiver and pushes metrics to SkyWalking OAP Server via OpenTelemetry gRPC exporter. The SkyWalking OAP Server parses the expression with to filter/calculate/aggregate and store the results. Set up . Set up . For details on Prometheus Receiver in OpenTelemetry Collector, refer to . Config SkyWalking . PostgreSQL cluster is cataloged as a `Layer: PostgreSQL` `Service` in OAP. Each PostgreSQL server is cataloged as an `Instance` in OAP. | Monitoring Panel | Unit | Metric Name | Description | Data Source | |--||--|--|--| | Shared Buffers | MB | meterpgshared_buffers | The number of shared memory buffers used by the server | postgres-exporter| | Effective Cache | GB | meterpgeffective_cache | The planner's assumption about the total size of the data caches | postgres-exporter| | Maintenance Work Mem | MB | meterpgmaintenanceworkmem | The maximum memory to be used for maintenance operations| postgres-exporter| | Seq Page Cost | | meterpgseqpagecost | The planner's estimate of the cost of a sequentially fetched disk page.| postgres-exporter| | Random Page Cost| | meterpgrandompagecost | The planner's estimate of the cost of a nonsequentially fetched disk page. | postgres-exporter| | Max Worker Processes | | meterpgmaxworkerprocesses | Maximum number of concurrent worker processes | postgres-exporter| | Max WAL Size | GB | metermaxwal_size | The WAL size that triggers a checkpoint | postgres-exporter| | Max Parallel Workers | | meterpgmaxparallelworkers | The maximum number of parallel processes per executor node| postgres-exporter| | Work Mem | MB | meterpgmaxworkmem | The maximum memory to be used for query workspaces. | postgres-exporter| | Fetched Row Trend | | meterpgfetchedrowsrate | The trend of the number of rows fetched by queries in this database. | postgres-exporter| | Inserted Row Trend | | meterpginsertedrowsrate | The trend of the number of rows inserted by queries in this database. | postgres-exporter| | Updated Row Trend | | meterpgupdatedrowsrate | The trend of the number of rows updated by queries in this database. | postgres-exporter| | Deleted Row Trend | | meterpgdeletedrowsrate | The trend of the number of rows deleted by queries in this database. | postgres-exporter| | Returned Row Trend | | meterpgreturnedrowsrate | The trend of the number of rows returned by queries in this

| postgres-exporter| | Committed Transactions Trend | | meterpgcommittedtransactionsrate | The trend of the number of transactions in this database that have been committed | postgres-exporter| | Rolled Back Transactions Trend | | meterpgrolledbacktransactions_rate | The trend of the number of transactions in this database that have been rolled back | postgres-exporter| | Buffers Trend | | meterpgbuffersalloc </br> meterpgbufferscheckpoint </br>meterpgbuffersclean </br>meterpgbuffersbackendfsync </br>meterpgbuffersbackend | The trend of the number of buffers | postgres-exporter| | Conflicts Trend | | meterpgconflicts_rate | The trend of the number of queries canceled due to conflicts with recovery in this database | postgres-exporter| | Deadlock Trend | | meterpgdeadlocks_rate | The trend of the number of deadlocks detected in this database | postgres-exporter| | Cache Hit Rate | % | meterpgcachehitrate | The rate of cache hit | postgres-exporter| | Temporary Files Trend | | meterpgtemporaryfilesrate | The rate of total amount of data written to temporary files by queries in this database. All temporary files are counted, regardless of why the temporary file was created, and regardless of the logtempfiles setting | postgres-exporter| | Checkpoint Stat Trend | | meterpgcheckpointwritetimerate </br> meterpgcheckpointsynctimerate </br> meterpgcheckpointreqrate </br>meterpgcheckpointtimedrate | The trend of checkpoint stat | postgres-exporter| | Active Sessions | | meterpgactive_sessions | The number of connections which state is active | postgres-exporter| | Idle Sessions | | meterpgidle_sessions | The number of connections which state is idle,idle in transaction or idle in transaction (aborted) | postgres-exporter| | Locks Count | | meterpglocks_count | Number of locks | postgres-exporter| You can customize your own metrics/expression/dashboard panel. The metrics definition and expression rules are found in `/config/otel-rules/postgresql`. The PostgreSQL dashboard panel configurations are found in `/config/ui-initialized-templates/postgresql`. SkyWalking leverages or other log agents for collecting slow SQL statements from PostgreSQL. fluentbit agent collects slow sql logs from PostgreSQL. fluentbit agent sends data to SkyWalking OAP Server using native log APIs via HTTP. The SkyWalking OAP Server parses the expression with to parse/extract and store the results. Set up . Config Config PostgreSQL to enable slow log. . Slow SQL monitoring provides monitoring of the slow SQL statements of the PostgreSQL server. PostgreSQL Cluster is cataloged as a `Layer: POSTGRESQL` `Service` in OAP. Each PostgreSQL server is cataloged as an `Instance` in OAP. | Monitoring Panel | Unit | Metric Name | Description | Data Source | |--||--|--|--| |Slow Statements | ms | topndatabase_statement | The latency and statement of PostgreSQL slow SQLs | fluentbit| You can customize your own metrics/expression/dashboard panel. The slowsql expression rules are found in `/config/lal/pgsql-slowsql.yaml` The PostgreSQL dashboard panel configurations are found in `/config/ui-initialized-templates/postgresql`.