Heroku PostgreSQL Monitoring
Heroku Postgres is great for getting started, but heroku pg:info and the dashboard only scratch the surface. MonPG gives you the query-level visibility you need as your application scales.
The Heroku PostgreSQL Visibility Gap
Heroku provides essential database metrics: row count, table size, cache hit ratio, and connection count. When an application slows down, the operational questions get sharper: Which queries are consuming the most time? Which tables need indexes? Is autovacuum keeping up? Are you approaching connection limits?
MonPG bridges this gap. By deploying a lightweight collector as a Heroku worker dyno, you get deep PostgreSQL monitoring that Heroku's built-in tools don't provide — without changing your database configuration.
What You Can Monitor on Heroku Postgres
- Query performance with pg_stat_statements: Heroku Standard and Premium plans have pg_stat_statements enabled. MonPG tracks every query — calls, execution time, rows processed, block I/O — with historical trends so you can see when performance started degrading.
- Connection tracking: Heroku plans have strict connection limits (20 for Hobby, 120 for Standard-0, 500 for Premium-0). MonPG tracks active, idle, and idle-in-transaction connections by application, helping you identify connection leaks before you hit the limit.
- Index recommendations: MonPG's index advisor analyzes your Heroku Postgres query patterns and recommends indexes with estimated impact. Stop guessing which indexes to create.
- Table bloat and vacuum: On Heroku's managed PostgreSQL, autovacuum runs automatically but may not be optimally tuned for your workload. MonPG tracks dead tuple accumulation and autovacuum effectiveness per table.
- Lock detection: Identify blocked queries and lock contention in real-time. See the lock tree to understand which query is blocking others.
- Heroku log collection: MonPG collects and analyzes Heroku Postgres logs via log drains, detecting slow queries, connection errors, and PostgreSQL-specific warnings that Heroku's logging doesn't surface.
Deploying on Heroku
The MonPG collector runs as a worker dyno in your Heroku app. It connects to your Heroku Postgres using the DATABASE_URL config var and pushes metrics to MonPG over HTTPS. Setup takes under 5 minutes:
- Add the MonPG collector buildpack or use the Docker deployment
- Set your
MONPG_API_KEYconfig var - Scale the worker dyno:
heroku ps:scale collector=1
The collector uses minimal resources — a single Hobby dyno is sufficient for monitoring. For production workloads, a Standard-1X dyno provides more headroom.
Heroku Plan Considerations
Not all Heroku Postgres plans support pg_stat_statements. Here's what you can monitor on each tier:
| Heroku Plan | pg_stat_statements | Connection Limit | MonPG Features |
|---|---|---|---|
| Essential-0 | Limited | 20 | Connections, locks, core metrics |
| Standard-0 | Yes | 120 | Full query analysis + all features |
| Premium-0 | Yes | 500 | Full query analysis + all features |
| Private/Shield | Yes | 500+ | Full features + VPC peering |
Outgrowing Heroku? Take MonPG With You
Many teams start on Heroku and eventually migrate to AWS RDS, Google Cloud SQL, or self-hosted PostgreSQL. With MonPG, your monitoring setup migrates with you. Same dashboards, same alerts, same query history — just point the collector at your new database.
Related Resources
- Connection Pooling with PgBouncer — Essential for Heroku's strict connection limits.
- PostgreSQL Index Optimization — Optimize queries before upgrading to a larger Heroku plan.
- How to Find and Fix Slow Queries — Diagnose performance issues on Heroku Postgres.
- PostgreSQL Slow Query Monitoring — Track slow query trends before upgrading to a larger Heroku plan.
See what Heroku's dashboard can't show you
Free trial — deploy the collector on a Hobby dyno in under 5 minutes.
Start trial