On a small team, watch six things in Postgres: whether it answers, connections in use against the limit, slow and failing queries, lock waits and long transactions, free disk, and replication lag if you run a replica. Get alerted at once when it is unreachable, when queries fail, or when connections or disk are about to run out.

A seventh, transaction ID age, moves slowly and is worth one check. Every Postgres fact below was checked against the PostgreSQL 18 documentation on November 13, 2026, the Amazon RDS facts against the AWS docs, and both are cited inline. Where a number is a rule of thumb and not something the docs state, it says so. Fixter (fixter.dev) is our product; the last sections show how we do this with it.

What to watch in Postgres, at a glance

Database monitoring means watching the few signals that say whether your database is reachable, fast and has room left, and getting alerted when one of them turns. Postgres exposes hundreds of counters. A team without a database administrator needs the few that say "users are affected now" or "they will be soon". These are the seven, with where Postgres shows each one and how urgent it is.

SignalWhere Postgres shows itWhat goes wrongAlert whenUrgency
ReachableA health endpoint that runs SELECT 1; pg_isreadyEvery request that needs data failsA few outside checks fail in a rowNow
Connectionspg_stat_activity against max_connectionsNew connections are refusedAbout 80% of the limit, held for minutes (rule of thumb)Now
Slow and failing queriespg_stat_statements; error codes; your app's tracesRequests slow down or return errorsFailures above normal; p95 well above its usual levelNow for failures, working hours for slow
Locks and long transactionspg_stat_activity, pg_blocking_pidsQueries queue behind one sessionA transaction or lock wait lasts minutes (rule of thumb)Now if requests are blocked
Diskpg_database_size; host or provider storage metricWrites stop; the server can shut downFree space below about 20%, or falling fast (rule of thumb)Working hours, now when nearly full
Replication lagpg_stat_replication (replay_lag)Stale reads; data lost on failoverLag stays above what your reads tolerateWorking hours
Transaction ID ageage(datfrozenxid) in pg_databasePostgres refuses new writesLong before the server's own warningWorking hours

"Rule of thumb" marks a starting value that is common practice, not a figure from the PostgreSQL docs. Tune it to your own traffic. Click a signal for the query and the detail.

Each signal, with the query that shows it

The queries below run in psql or any SQL client, with a role that can read the statistics views. They only read.

1. Is it reachable

The first question is whether your app can reach the database at all. The check that answers it is a health endpoint in your app that runs SELECT 1 and returns a 503 when the query fails, called from outside every minute or so. The code and the alert routes are in how do I know when my app or database goes down. If you run Postgres yourself, pg_isready answers the same question from the command line: it exits with 0 when the server accepts connections, 1 when it rejects them, and 2 when there is no response.1

2. Connections

Every Postgres server has a hard limit on concurrent connections, max_connections. The default is typically 100, and three of those slots are reserved for superusers by default, so an app role runs out a little earlier.2 Past the limit, a new connection fails with error code 53300, too_many_connections.4 On a small app this is the classic outage: a deploy doubles the number of app instances, each with its own pool, and the database starts refusing connections while its CPU sits idle.

psql
-- connections in use, by state, against the limit
SELECT state,
       count(*) AS connections,
       current_setting('max_connections') AS max_connections
FROM pg_stat_activity
WHERE backend_type = 'client backend'
GROUP BY state
ORDER BY connections DESC;

pg_stat_activity has one row per server process, and the state column says what each connection is doing: active, idle, or idle in transaction, which means a transaction is open and no query is running.3 Many idle connections point at pools that are too large. Many idle in transaction point at code that opens a transaction and then waits on something else. On Amazon RDS the default limit is not 100: it is derived from the instance's memory, capped at 5,000, and the count is published as the DatabaseConnections metric.14,12

3. Slow and failing queries

Inside the database, the pg_stat_statements extension keeps a row per normalized query, with constants replaced, and records how often it ran and how long it took. It has to be added to shared_preload_libraries, which needs a server restart, and then enabled with CREATE EXTENSION pg_stat_statements in the database you query.5

psql
-- needs the pg_stat_statements extension
SELECT calls,
       round(mean_exec_time) AS mean_ms,
       round(total_exec_time) AS total_ms,
       query
FROM pg_stat_statements
ORDER BY total_exec_time DESC
LIMIT 10;

Sort by total time, not mean time. A 20 ms query that runs a million times a day costs more than a 3 second report that runs twice. For the log view, log_min_duration_statement writes every statement that runs for at least the value you set to the server log; it is off by default.6 Once you have the slow query, why is my database query slow covers the causes and how to read the plan.

Failing queries carry a five character error code. The ones worth knowing by sight: 53300 too many connections, 53100 disk full, 40P01 deadlock detected, and 57014 query canceled, the code a statement timeout raises.4 pg_stat_database also counts rollbacks and deadlocks per database.3 A rise in any of these is a user seeing an error.

4. Locks and long transactions

One session that holds a lock and does not finish can stall everything behind it. The usual causes are a migration that takes a table lock during traffic and a transaction left open by application code. The query below lists the oldest open transactions and, through pg_blocking_pids, which sessions are blocking each one.8

psql
-- oldest open transactions, and who is blocking them
SELECT pid,
       state,
       now() - xact_start AS open_for,
       pg_blocking_pids(pid) AS blocked_by,
       left(query, 60) AS query
FROM pg_stat_activity
WHERE xact_start IS NOT NULL
ORDER BY xact_start
LIMIT 10;

Two settings turn this from something you find into something Postgres prevents. idle_in_transaction_session_timeout ends a session that sits idle inside an open transaction for longer than the value you set, and statement_timeout aborts any statement that runs too long. Both are disabled by default.7 An open transaction also stops vacuum from removing dead rows, so it grows your tables as well as blocking your queries.7 With log_lock_waits on, Postgres logs any session that waits on a lock for longer than deadlock_timeout.6

5. Disk

The PostgreSQL docs call keeping the disk from filling the most important disk monitoring task. A full data disk does not corrupt data, but it stops useful work, and if the disk that holds the write-ahead log fills, the server can panic and shut down.9 Postgres can tell you how large the database is, not how much room is left:10

psql
SELECT pg_size_pretty(pg_database_size(current_database()));

Free space comes from the host or the provider. On Amazon RDS it is the FreeStorageSpace metric, and an instance that runs out moves to the storage-full status and may stop being available.12,13 Watch the trend as well as the level: a database at 60% that grows 5% a week needs attention sooner than one that has sat at 80% for a year.

6. Replication lag, if you have a replica

Skip this one if you run a single instance. With a replica, lag matters twice: reads from the replica show old data, and after a failover the lag is what you lost. On the primary, pg_stat_replication has a row per connected replica, and for an asynchronous replica its replay_lag column approximates the delay before recent transactions became visible to queries there.3

psql
-- on the primary: one row per connected replica
SELECT application_name, state, replay_lag
FROM pg_stat_replication;

-- on the replica: time since the last replayed transaction
SELECT now() - pg_last_xact_replay_timestamp() AS behind;

Two traps. A replica that is missing from pg_stat_replication is not lagging, it is disconnected, so alert on the row count too. And the replica-side query measures time since the last replayed transaction, so on a database with no writes it grows even when the replica is fully caught up.10 On Amazon RDS the equivalent is the ReplicaLag metric, in seconds.12

7. Transaction ID age

This one is rare and total. Postgres numbers transactions with a 32 bit counter, and vacuum has to freeze old rows before the counter wraps around. Autovacuum normally handles it. If it cannot, for example because a long transaction or a stuck vacuum blocks it, Postgres starts logging warnings when the oldest transaction IDs are 40 million from the wraparound point, and refuses to assign new transaction IDs when fewer than 3 million are left.11 At that point the database stops taking writes.

psql
SELECT datname, age(datfrozenxid) FROM pg_database;

The age should stay far below two billion. Autovacuum is started on any table whose oldest transaction IDs pass autovacuum_freeze_max_age, 200 million by default, even when autovacuum is turned off, so the age should fall back each time it gets there.11 A value that keeps climbing past that setting means vacuum is not keeping up. Check it monthly, or alert on it; RDS publishes it as MaximumUsedTransactionIDs.12

When to get alerted, and when it can wait

An alert should interrupt you only when users are affected now or will be within the hour. Everything else is a message you read during working hours. Split the seven signals that way:

  • Interrupt now. The health check failed several runs in a row. Database calls are failing well above their normal rate. Connections are close to the limit and staying there. Free disk is nearly gone. Requests are queueing behind a lock.
  • Tell me in working hours. Query latency has drifted up. Disk passed its early threshold. Replication lag is above normal. A transaction has been open for a long time without blocking anyone. Transaction ID age is climbing.

Three habits keep the alerts trustworthy. Require the condition to hold for several checks in a row, so one spike does not page you. Compare against the service's own normal where you can, because "slow" for a reporting query is not "slow" for a login. And alert on what users feel first, failing and slow requests, before the internal counters: a connection count at 85% with no errors is a warning, the same count with failing requests is an outage.

What you can see without touching the database

Most of the urgent signals do not need a monitoring tool to hold database credentials. They reach you from three places you already have.

  • Your app's traces. OpenTelemetry auto-instrumentation wraps the database driver, so each query becomes a span with its timing inside the request that ran it. Under the current OpenTelemetry conventions the span is tagged db.system.name = postgresql, and a failed query carries the Postgres error code.15 Older instrumentations still send the previous name, db.system, until you opt in to the new one.27 That gives you slow and failing queries per route, and connection errors, with no access to the database itself.
  • An outside check. A request to your health endpoint from outside your infrastructure covers reachability, including the cases where your own monitoring went down with the app.
  • Your provider's metrics. A managed database publishes connections, free storage and replica lag. On RDS those are CloudWatch metrics.12

What stays inside the database: which session holds a lock, dead rows per table, transaction ID age. Those need a query, by you or by an agent with a read-only role. If you let a coding agent run them, guard the database first.

Set it up in five steps

This is the setup with Fixter, in the order that gets you covered fastest. Each step is something you ask your coding agent to do.

  1. Send your app's traces. Paste Read fixter.dev/llms.txt and set up Fixter. into Claude Code, Cursor or Codex. Your app sends standard OpenTelemetry, and auto-instrumentation covers the database driver, so queries appear as spans with their timing.16 From then on Fixter's detectors alert on error bursts and on latency getting worse with no rules from you.19
  2. Check the database from outside. Add a health endpoint that runs SELECT 1, then ask your agent to create an HTTP test on it. The test checks the status code and, if you set one, a maximum latency.17 It can run as often as every 30 seconds and goes down after three failed runs in a row by default. The URL has to be reachable from the public internet.18
  3. Add a rule for your Postgres calls. Ask for an alert on spans filtered to db.system.name = 'postgresql', one on p95 latency and one on error rate, each required to hold for several windows in a row. If your instrumentation still sends db.system, Fixter stores it as db.system.name, so the same filter matches.19,20 Failing queries also show up without a rule: errors in your traces and logs are grouped into issues, one per root cause.21
  4. Bring in disk, connections and replica lag. On Amazon RDS, send the AWS/RDS CloudWatch namespace to Fixter through a metric stream, then add metric rules on FreeStorageSpace, DatabaseConnections and ReplicaLag. RDS Postgres logs can come the same way.22 On Kubernetes, the Fixter collector chart sends host metrics and parses Postgres logs.23
  5. Break it on purpose. In staging, point the app at a wrong database URL and confirm the test goes down and the alert reaches you. Then ask the questions you will ask during a real incident, so you know the answers are there.
claude code
> which queries got slower this week, and on which routes?
> are any database calls failing right now? group them by error
> what did the api service do in the minute before /health went down?
> alert me when p95 of our Postgres calls stays high for 10 minutes

Doing it with Fixter

Fixter is ours, so weigh this section with that in mind. Fixter finds and fixes the issues in your app in production, from your coding agent: errors, failing infrastructure, slow requests and downtime. It finds the root cause and fixes it: in your agent over MCP, or as a pull request ready for your review. Nothing to learn, built for small teams.

For a database, that means you do not set up database monitoring as a separate project. The database's trouble arrives through the app you already instrumented: a query that got slow, a pool that ran out, a migration that locked a table all show up as slow or failing requests, grouped into one issue with a trace that leads to the query and the route. Uptime monitoring covers the database being unreachable. Alerts arrive by email or Slack, and on the paid plans an investigation works out the root cause and who was affected before you open it.26

Where it stops, so you can plan around it. Fixter does not connect to your database and does not read pg_stat_activity or pg_stat_statements. Host disk and memory arrive only through the Kubernetes collector chart or your cloud provider's metrics, and the collector has no Postgres metrics receiver yet.16,23 If you want the inside counters as metrics, run a standard OpenTelemetry Collector with its PostgreSQL receiver and a read-only monitoring user. The receiver's metrics are in beta, and by default they include connections against the limit, database size and replication lag.25,28 One exporter block sends them to Fixter, where any metric you send can carry an alert rule.24,19

The free plan covers the first three steps for a small app: 50,000 uptime checks a month, enough for one endpoint every minute, and 5 alert rules. Paid plans start at €20 a month.26 For the wider picture of what to watch once the database is covered, see monitoring errors in production and the best monitoring tools for a small SaaS.

Key takeaways

  • Seven signals cover a small Postgres: reachable, connections, slow and failing queries, locks, disk, replication lag, transaction ID age
  • max_connections is typically 100 by default with 3 slots reserved; past it, new connections fail with error 53300
  • Interrupt for unreachable, failing queries, connections near the limit and disk nearly full; the rest can wait for working hours
  • Slow and failing queries are visible in your app's traces, with no database credentials handed to a tool
  • Postgres warns at 40 million transaction IDs from wraparound and refuses writes at 3 million

Frequently asked questions

What should I monitor in Postgres?

Seven things cover most trouble on a small app: whether the database answers, connections in use against max_connections, slow and failing queries, lock waits and long open transactions, free disk space, replication lag if you run a replica, and transaction ID age. The first five are the ones that take an app down without warning.

How do I get alerted when my database goes down?

Give your app a health endpoint that runs SELECT 1 and returns a 503 when the query fails, then point an outside check at it and alert after a few failed runs in a row. A managed database usually has no public port, so checking through your app is the reliable way. Add an alert on failing database calls for the cases where it is up but refusing work.

How many connections is too many in Postgres?

The limit is max_connections, which PostgreSQL's docs put at typically 100 by default, with three slots reserved for superusers. Past the limit, new connections fail with too_many_connections. A common rule of thumb is to alert at about 80 percent of the limit, held for a few minutes, so you hear about it before the errors start. Amazon RDS sets its own default from the instance's memory.

How do I find slow queries in Postgres?

Inside the database, the pg_stat_statements extension records calls, mean time and total time per normalized query; sort by total time to see what costs the most. From the app side, OpenTelemetry auto-instrumentation records every query as a span with its timing inside the request that ran it, so you see the slow query and the route it slowed down.

What is replication lag, and when should I alert on it?

Replication lag is how far a replica is behind the primary. PostgreSQL shows it as replay_lag in pg_stat_replication on the primary. It matters when your app reads from the replica, because users see stale data, and when the replica is your failover, because lag is the data you would lose. There is no universal number: alert when lag stays above what your reads can tolerate.

Can I monitor Postgres without giving a tool database access?

Mostly, yes. Slow and failing queries show up in your app's own traces, an outside check on a health endpoint covers reachability, and a managed provider publishes disk, connections and replica lag as metrics. What you cannot see from outside is the inside view: which session holds a lock, dead rows per table, transaction ID age. Those need a query against the database.

Do I need a separate database monitoring tool?

A small team usually does not. Start with what you already have: traces from your app, an outside check, and your provider's metrics, all alerting to the same place as your app's errors. A dedicated database tool earns its place when someone's job is tuning the database. Before that, it is one more console nobody opens.

Sources (28), all checked November 13, 2026
  1. PostgreSQL 18 docs, pg_isready (exit status)
  2. PostgreSQL 18 docs, connection settings (max_connections, superuser_reserved_connections)
  3. PostgreSQL 18 docs, the cumulative statistics system (pg_stat_activity, pg_stat_database, pg_stat_replication, pg_stat_user_tables)
  4. PostgreSQL 18 docs, error codes (53300, 53100, 40P01, 57014)
  5. PostgreSQL 18 docs, pg_stat_statements
  6. PostgreSQL 18 docs, logging settings (log_min_duration_statement, log_lock_waits)
  7. PostgreSQL 18 docs, client connection defaults (statement_timeout, idle_in_transaction_session_timeout)
  8. PostgreSQL 18 docs, system information functions (pg_blocking_pids)
  9. PostgreSQL 18 docs, monitoring disk usage (disk full failure)
  10. PostgreSQL 18 docs, system administration functions (pg_database_size, pg_last_xact_replay_timestamp)
  11. PostgreSQL 18 docs, routine vacuuming (transaction ID wraparound)
  12. AWS docs, Amazon CloudWatch metrics for Amazon RDS
  13. AWS docs, troubleshooting Amazon RDS (DB instance running out of storage)
  14. AWS docs, quotas and constraints for Amazon RDS (maximum database connections)
  15. OpenTelemetry, semantic conventions for PostgreSQL client operations
  16. Fixter docs, telemetry (what you get without writing code, what is not included)
  17. Fixter docs, HTTP tests (status pattern, max latency)
  18. Fixter docs, runs, states and uptime (interval, failure threshold, addresses Fixter will not test)
  19. Fixter docs, alerts (detectors, sources and measures, consecutive windows, where alerts arrive)
  20. Fixter docs, QuerySQL (span attributes such as db.system.name)
  21. Fixter docs, issues (grouping, Postgres server errors in logs)
  22. Fixter docs, AWS Firehose (CloudWatch metric streams and RDS logs)
  23. Fixter docs, Kubernetes collector (host metrics, Postgres logs, no datastore metrics yet)
  24. Fixter docs, send data with OpenTelemetry (adding Fixter to a Collector)
  25. OpenTelemetry Collector contrib, PostgreSQL receiver README (config and permissions)
  26. Fixter pricing (checks, alert rules and investigations per plan)
  27. OpenTelemetry, database semantic conventions (moving instrumentations to the stable names)
  28. OpenTelemetry Collector contrib, PostgreSQL receiver metadata (stability, metrics on by default)