PostgreSQL Metrics with InstrumentalD

PostgreSQL logo

The best way to get PostgreSQL metrics into Instrumental is with InstrumentalD, the fast and reliable server agent created by the Instrumental team. By using InstrumentalD to collect PostgreSQL metrics, you'll get premade PostgreSQL graphs and unlock the full power of our Query Language.

Quick Start

Check out our Installation Instructions for more details. Otherwise, here's the bare minimum to get up and running.

brew install instrumental/instrumentald/instrumentald
echo 'postgresql = ["postgres://postgres@localhost?sslmode=disable"]' >> instrumentald.toml
instrumentald -c instrumentald.toml -k PROJECT_TOKEN
curl https://packagecloud.io/install/repositories/expectedbehavior/instrumental/script.deb.sh | sudo bash
sudo apt-get install instrumentald
sudo echo 'project_token = "PROJECT_TOKEN"' > /etc/instrumentald.toml
sudo echo 'postgresql = ["postgres://postgres@localhost?sslmode=disable"]' >> /opt/instrumentald.toml
sudo systemctl start instrumentald
curl https://packagecloud.io/install/repositories/expectedbehavior/instrumental/script.rpm.sh | sudo bash
sudo yum install instrumentald
sudo echo 'project_token = "PROJECT_TOKEN"' > /etc/instrumentald.toml
sudo echo 'postgresql = ["postgres://postgres@localhost?sslmode=disable"]' >> /opt/instrumentald.toml
sudo service instrumentald restart

Configuring InstrumentalD

InstrumentalD will collect the metrics below from as many PostgreSQL servers as configured. Here's a basic example of the PostgreSQL config:

postgresql = ["postgres://postgres@localhost?sslmode=disable"]

Everything you need to know about configuring InstrumentalD, including more information about PostgreSQL config, can be found in the InstrumentalD Configuration docs.

Metrics Collected

All PostgreSQL metrics collected by InstrumentalD follow this pattern:

postgres.<host from connection string>.<database name>.<metric>
The following metrics are collected:
blk_read_time Time spent reading data file blocks by backends in this database, in milliseconds
blk_write_time Time spent writing data file blocks by backends in this database, in milliseconds
blks_read Number of disk blocks read in this database
deadlocks Number of deadlocks detected in this database
numbackends Number of backends currently connected to this database. This is the only column in this view that returns a value reflecting current state; all other columns return the accumulated values since the last reset
temp_bytes 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 log_temp_files setting
tup_deleted Number of rows deleted by queries in this database
tup_fetched Number of rows fetched by queries in this database
tup_inserted Number of rows inserted by queries in this database
tup_returned Number of rows returned by queries in this database
tup_updated Number of rows updated by queries in this database
xact_commit Number of transactions in this database that have been committed
xact_rollback Number of transactions in this database that have been rolled back
The following are only reported once per connection, as this is cluster-level information, rather than database.
checkpoint_sync_time Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk, in milliseconds
checkpoint_write_time Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds

How many metrics can I expect from InstrumentalD?

InstrumentalD will collect 15 metrics per PostgreSQL database configured.

Suggested Graphs

The following graphs are based on the metrics collected by InstrumentalD, and provide great starting point for monitoring PostgreSQL.

Log in or sign up to add them to your project.

Questions? We can help!