Monitoring PostgreSQL

Configure the Server Density agent to monitor your PostgreSQL server to:

• Collect important metrics, such as connections, commits, indexes etc 
• Identify overall server slowdowns caused by the server

Monitored metrics

  • Tables 
    • Count
  • Percent Usage Connections
  • BG Writer
    • Buffers Backend
    • Checkpoints Timed
    • Buffers Allocated
    • Buffers Clean
    • Checkpoints Requested
    • Buffers Backend Fsync
    • Max Written Clean
    • Buffers Checkpoint
  • Databases 
    • Count
    • Max Connections
    • Database Size
    • Rows Inserted
    • Commits
    • Rows Fetched
    • Rows Updated
    • Connections
    • Rows Deleted
    • Disk Read
    • Rollbacks
    • Buffer Hit
    • Rows Returned

Installing the PostgreSQL plugin package

Install the PostgreSQL plugin on Debian/Ubuntu:

sudo apt-get install sd-agent-postgresql

Install the PostgreSQL plugin on RHEL/CentOS:

sudo yum install sd-agent-postgresql

Read more about agent plugins.

Configuring the agent to monitor PostgreSQL

1. Connect to psql and create a monitoring user:

CREATE USER serverdensity WITH PASSWORD 'supersecretpassword';
GRANT SELECT ON pg_stat_database TO serverdensity;

2. Configure /etc/sd-agent/conf.d/postgres.yaml

init_config:

instances:
- host: localhost
port: 5432
username: serverdensity
password: supersecretpassword

3. Restart the agent

sudo /etc/init.d/sd-agent restart

Verifying the configuration
Execute info to verify the configuration with the following:

sudo /etc/init.d/sd-agent info 

If the agent has been configured correctly you’ll see an output such as:

postgres
-----
  - instance #0 [OK]
  - Collected 20 metrics & 1 service checks

You can also view the metrics returned with the following command:

sudo -u sd-agent /usr/share/python/sd-agent/agent.py check postgres

Configuring graphs

Click the name of your server from the Devices list in your Server Density account then go to the Metrics tab. Click the + Graph button on the right then choose the PostgreSQL metrics to display the graphs. The metrics will also be available to select when building dashboard graphs.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Monday  —  Friday.

10am  —  6pm UK.

Dedicated Support.