Skip to content


PostgreSQL is a powerful open-source relational database management system (RDBMS) known for its robustness, extensibility, and compliance with SQL standards. The Sematext Agent collects PostgreSQL metrics and logs, transmits them to Sematext Cloud; installing the agent takes less than 5 minutes.

Install Sematext Agent

  1. Create an PostgreSQL Logs or Monitoring App. This will let you install the agent and control access to your monitoring and logs data.
  2. Install the Sematext Agent according to the displayed in the UI.
  3. After installing the agent, the Discovery tab shows all the PostgreSQL services identified on the host and you will start receiving metrics or logs from PostgreSQL services.
  4. If you've created an PostgreSQL Monitoring App and want to collect PostgreSQL logs as well, or vice versa, click on the Create Logs App button from the left menu panel. This will navigate you to the 'Create Logs App' (or Monitoring App) page, where you'll find all the discovered log sources from PostgreSQL services and manage log and metric shipping effortlessly.

Having both PostgreSQL Logs and Monitoring Apps lets you correlate performance metrics and logs, and accelerate troubleshooting using Split Screen for faster resolution. For example, if you see a spike in number of rows fetched, you can check logs to see which queries fetch too many rows. A concrete example of doing that can be found in this article. Or if you notice expensive queries in the logs, monitoring can tell you whether they hit the indices or they were mostly scans.

To explore logs and services across multiple hosts, navigate to Fleet & Discovery > Discovery > Services (or Sematext Cloud Europe). From there, you can create additional Apps or stream data to existing ones without requiring any additional installations.

From number of rows and connections to index and function-specific metrics, all the relevant stats are collected and displayed in built-in dashboards:

PostgreSQL Monitoring Overview

Important PostgreSQL Metrics to Watch

You'd normally start from the Overview screen to check the higher-level metrics, such as number of rows or connections over time. Other high-level metrics can be found under Activity or Tables dashboards:

PostgreSQL Monitoring Tables

Then, if necessary, you can dive deeper into a specific direction. For example, if you think that indexes are over-used or not used enough, you can check their metrics in the Indexes dashboard. Like how often the index blocks are hit:

PostgreSQL Monitoring Indexes

Finally, OS-level metrics can also point out bottlenecks, such as network or CPU:

PostgreSQL CPU Chart

You can find a full list of PostgreSQL-specific metrics that are collected below.


Metric Name
Key (Type) (Unit)
active backends use
(long gauge)
Number of backends executing a query
idle backends
(long gauge)
Number of backends in a transaction, but not currently executing a query
WAL files
Number of WAL files that have been successfully archived
failed WAL files
Number of failed attempts to archive WAL files
scheduled checkpoints
Number of scheduled checkpoints that have been performed
requested checkpoints
Number of requested checkpoints that have been performed
checkpoint buffers
Number of buffers written during checkpoints
cleaned buffers
Number of buffers written by the background writer
max written clean buffers
Number of times the background writer stopped a cleaning scan because it had written too many buffers
backend buffers
Number of buffers written directly by a backend
allocated buffers
Number of buffers allocated
active connections
(long gauge)
Number of backends currently connected to this database
committed transactions
Number of transactions in this database that have been committed
rolled back transactions
Number of transactions in this database that have been rolled back
disk blocks read
Number of disk blocks read in this database
disk block cache hit
Number of times disk blocks were found already in the buffer cache, so that a read was not necessary (this only includes hits in the PostgreSQL buffer cache, not the operating system's file system cache)
rows returned
Number of rows returned by queries in this database
rows fetched
Number of rows fetched by queries in this database
rows inserted
Number of rows inserted by queries in this database
rows updated
Number of rows updated by queries in this database
rows deleted
Number of rows deleted by queries in this database
max connections
(double gauge)
Maximum number of concurrent connections to the database server. Parameter set at server startup
percent usage connections
(double gauge)
Percentage of used connections (ratio between number of active backends and maximum allowed connections)
table count
(long gauge)
Number of tables in this DB
function calls
Number of times this function has been called
function total time
Total time spent in this function and all other functions called by it, in milliseconds
function self time
Total time spent in this function itself, not including other functions called by it, in milliseconds
index scan
Number of index scans initiated on this index
returned index entries
Number of index entries returned by scans on this index
fetched rows
Number of live rows fetched by index scans
lock count
(long gauge)
Number of active lockable objects
sequential scans
Number of sequential scans initiated on a table
sequential rows fetched
Number of live rows fetched by sequential scans
index rows fetched
Number of live rows fetched by index scans
inserted rows
Number of rows inserted
updated rows
Number of rows updated
deleted rows
Number of rows deleted
hot updated rows
Number of rows hot updated (i.e., with no separate index update required)
live rows
(long gauge)
Estimated number of live rows
dead rows
(long gauge)
Estimated number of dead rows
replication delay
(long gauge)
Replication delay in milliseconds
replication delay bytes
(long gauge)
Replication delay in bytes
table size
(long gauge)
Disk space used by the a table, excluding indexes (but including TOAST, free space map, and visibility map)
index size
(long gauge)
Total disk space used by indexes attached to the a table
total size
(long gauge)
Total disk space used by the a table, including all indexes and TOAST data
read disk blocks
Number of disk blocks read from a table
hit disk blocks
Number of buffer hits in a table
read index blocks
Number of disk blocks read from all indexes on a table
hit index blocks
Number of buffer hits in all indexes on a table
read TOAST blocks
Number of disk blocks read from a table's TOAST table (if any)
hit TOAST buffers
Number of buffer hits in a table's TOAST table (if any)
read TOAST index
Number of disk blocks read from a table's TOAST table index (if any)
hit TOAST buffer
Number of buffer hits in a table's TOAST table index (if any)


Once data is in, you can explore it via the built-in reports:

PostgreSQL Logs Overview

Exploring logs

Once data is in, you can explore it using the built-in reports or create your own. For example, you can use the Statement Duration report to check on your queries:

PostgreSQL Statement Duration Report


If you are having trouble sending logs, try out the latest version of the Sematext Agent. Additionally, make sure to check out the Log Agents panel for any errors, and refer to our Sematext Logs FAQ for useful tips.

If you are having issues with Sematext Monitoring, i.e. not seeing PostgreSQL metrics, see How do I create the diagnostics package.

For more troubleshooting information please look at the Troubleshooting section.