PostgreSQL Integration

Configure the Watchlog Agent to monitor your PostgreSQL databases, tables, and query performance.

1. Install Watchlog Agent

2. Configure Integration

After installing the agent, open integration.json in your agent directory and add the PostgreSQL block:


  {
    "service": "postgresql",
    "monitor": true,
    "host": "localhost",
    "port": "5432",
    "username": "YOUR_USERNAME",
    "password": "YOUR_PASSWORD",
    "database": ["postgres"]
  }
  

2.5. Enable Query Performance Metrics (pg_stat_statements)

  1. Edit postgresql.conf:
    shared_preload_libraries = 'pg_stat_statements'
  2. Restart PostgreSQL:
    sudo systemctl restart postgresql
  3. Enable the extension: Connect to each database and run:
    CREATE EXTENSION pg_stat_statements;
  4. Verify: Execute:
    SELECT * FROM pg_stat_statements LIMIT 5;
    to confirm the extension is active.

3. Restart Watchlog Agent

Linux Restart

sudo pm2 restart watchlog-agent

Windows Restart

Restart-Service -Name "WatchlogAgent"

Explore PostgreSQL Monitoring Capabilities

Database Overview

Tables count, indexes count, total database size, and uptime since last restart.

Live Records

Monitor records inserted, updated, and deleted in real time.

Connection Load

Track active vs idle connections to identify bottlenecks instantly.

Cache & Disk Blocks

Cache hit rate vs disk reads to optimize memory usage and minimize I/O.

Lock & Query Analysis

Monitor active vs waiting locks, blocked queries, and deadlock incidents.

Transaction Outcomes

Track committed vs rolled back transactions for stability insights.

Tuples Stats

Compare returned vs fetched tuples to identify inefficient queries.

Query Performance

Normalized query view with count, total & average duration, and rows.

All metrics available in real time or over custom time ranges via the Watchlog dashboard.

Start Monitoring PostgreSQL