OPEN SOURCE · FREE TO INSTALL

Install PG Monitoring Extension (`pg_monitor`)

Install the PostgreSQL extension on your on-premise server in under 2 minutes. Supports PostgreSQL 13–17 on Debian, Ubuntu, RHEL, Rocky and CentOS.

One-liner (recommended)

Auto-detects your OS and PostgreSQL version.

$ curl -fsSL https://pgmonitoring.com/install.sh | sudo bash

APT Repository (Recommended)

# Add repository
curl -fsSL https://pgmonitoring.com/gpg.key | sudo gpg --dearmor \
  -o /usr/share/keyrings/pgmonitoring.gpg

echo "deb [signed-by=/usr/share/keyrings/pgmonitoring.gpg] \
  https://apt.pgmonitoring.com stable main" \
  | sudo tee /etc/apt/sources.list.d/pgmonitoring.list

sudo apt-get update

# Install for your PostgreSQL version:
sudo apt-get install postgresql-16-pg-monitor   # PG 16
sudo apt-get install postgresql-15-pg-monitor   # PG 15
sudo apt-get install postgresql-14-pg-monitor   # PG 14

After Installation

1

Enable in postgresql.conf

shared_preload_libraries = 'pg_monitor'
pg_monitor.collection_interval = 60      # seconds between metric pushes
pg_monitor.api_endpoint = 'https://pgmonitoring.com/api/v1/agent/metrics'
pg_monitor.api_token = 'your-instance-token'
2

Restart PostgreSQL

sudo systemctl restart postgresql
3

Create the extension

psql -U postgres -c "CREATE EXTENSION IF NOT EXISTS pg_stat_statements;"
psql -U postgres -c "CREATE EXTENSION IF NOT EXISTS pg_monitor;"

Verify it's working

psql -U postgres -c "SELECT * FROM pgmon.health_check();"

On RDS, Cloud SQL or Aurora? Use the agent instead — not this extension.

This extension needs shared_preload_libraries, which managed databases don't allow. For managed Postgres, install the lightweight Python agent on any host that can reach your database: it pushes metrics every 60s using only your instance token — no extension and no password stored on disk (credentials are fetched securely over HTTPS). Grab the per-instance setup snippet from each instance's page.

Ready to connect your instance to PG Monitoring?

Sign in to add your instance
Talk to us