PostgreSQL alerting: what to alert on

A practical PostgreSQL alert set covering availability, replication lag, transaction ID age, disk and WAL growth, connections, long transactions, archiving and backup age, with severity guidance.

On this page

What PostgreSQL alerting should catch before users do

A self-hosted PostgreSQL estate usually fails in one of two ways: it pages the on-call engineer dozens of times a week for conditions nobody acts on, or it stays silent until a backup is missing or a disk is full. The conditions that deserve an alert are the ones that threaten availability, data recovery or the ability to write. Keep that set small, tie each alert to a recovery point or availability goal your organization has agreed, and route each one by severity so a warning goes to a ticket queue while a condition that stops writes wakes someone up. Before writing any rule, confirm your recovery point objective and recovery time objective with the business owners, because those numbers decide how fast replication lag or backup age must be caught.

The alerts themselves depend on metrics that the monitoring setup collects, such as availability, replication position, transaction ID age, disk and WAL growth, connection counts, long-running transactions, archiver status and the time of the last successful backup. Prometheus and Alertmanager are one common way to evaluate these rules and route notifications, with Prometheus evaluating the expressions and Alertmanager handling grouping, silences and delivery. The same logic can be built in Zabbix or another platform. Whichever tool you choose, confirm that the metric names, label sets and scrape permissions are in place before you rely on an alert, since a rule that evaluates against missing data will often stay quiet rather than fire.

Treat every alert as a decision. For each candidate, write down who responds, within what time, and what the first action is. An alert with no owner or no action should be downgraded to a dashboard panel. Start with a short list of critical conditions and add warnings only after you have reviewed a few weeks of firing history, because thresholds that suit a small write-heavy cluster will not suit a reporting replica. Ask your implementation partner or internal team to document the threshold reasoning next to each rule so that later tuning is a reviewed change, not a guess.

The core alert set and what each alert protects

Each card names one failure family, the signal worth alerting on, and the consequence if nobody is told. The families overlap in practice: a stalled replica, a full WAL volume and a long-running transaction often appear together, so read them as one set rather than eight separate dashboards. Confirm every threshold against your own workload and recovery targets.

Availability

Alert when the PostgreSQL server stops accepting connections or a health probe fails, and separately when the primary is no longer the node your applications write to. A single failed scrape can be noise, so pair the alert with a short confirmation window and a check from outside the database host. Without this alert, applications report errors before anyone on call knows the database is down. Confirm how your failover tooling reports role changes so the alert fires on the right event.

Failover docs

Replication lag

Alert when a standby falls behind the primary by more than the amount your recovery point objective allows, measured in both time and bytes of WAL. Track write, flush and replay positions separately, because a standby can receive WAL while still replaying it. Unchecked lag means failover can lose more committed data than the business accepted, and read replicas serve stale results. Also watch replication slots, since an inactive slot holds WAL on the primary.

Transaction ID age

Alert on the age of the oldest unfrozen transaction ID per database, long before autovacuum is forced to run in emergency mode. Warnings should escalate as the age approaches the wraparound limit, and the alert should name the database and table with the oldest value. If ignored, the server can stop accepting write commands to protect data integrity, which is a full write outage. Confirm the limit and freeze settings that apply to your version before setting levels.

Disk and WAL growth

Alert on free space for the data, WAL and archive volumes separately, and on the rate of growth, not just the level. WAL can grow quickly when a replica disconnects, an archive command fails or a replication slot is inactive. A full volume stops the server from writing WAL, which halts commits. Check which volumes share a filesystem, because a log or backup directory on the data disk can cause the outage.

Connection saturation

Alert when client connections approach max_connections, and when the pooler's client or server queues grow, since PgBouncer can hold clients while the database is full. Track connections by state, because many idle-in-transaction sessions consume slots without doing work. Saturation shows up to applications as connection refused or timeout errors, often during traffic peaks. Confirm which limits sit in the database, the pooler and the application, because each can be the first to fail.

Long transactions

Alert on transactions and idle-in-transaction sessions that have run longer than an agreed limit, using the start time of the transaction rather than the connection time. Long transactions hold back vacuum cleanup, grow table bloat and can hold locks that block other sessions. Include the usernames and application names in the alert so the owning team can act. Confirm the limits with the application teams, since batch jobs can legitimately run long.

Failed archiving

Alert when the archiver reports failed WAL segment archive attempts or when the last successful archive time stops advancing. Archiving failures do not stop the primary, so the database looks healthy while recovery coverage shrinks. Each unarchived segment widens the gap that point-in-time recovery can cover. Pair the alert with a check of the archive destination's free space and credentials, because the archive command often fails for reasons outside PostgreSQL.

Backup age

Alert when the most recent successful base backup or verified backup is older than the agreed schedule allows, and when a restore test has not run within its planned interval. A backup job can exit without error while producing unusable output, so measure the success of the restore rather than the job status alone. Missing backups are discovered during an incident unless this alert exists. Confirm the backup schedule with the recovery targets your business has set.

Why transaction ID age and WAL growth need early warning

Transaction ID age has to be alerted long before it reaches its limit, because the database cannot simply wait it out. As transaction IDs advance, PostgreSQL must periodically freeze old rows so the counter can keep wrapping safely. Autovacuum normally does this quietly in the background. When it falls behind, perhaps because a long-running transaction holds back the cleanup horizon or because tables are not being vacuumed fast enough, the server escalates to emergency anti-wraparound vacuum work. That work runs regardless of other load, competes with production queries, and can take hours on large tables. Alert on the age of datfrozenxid per database and on the age of the oldest relation, with at least two warning levels so there is time to find the blocker, not only to watch the vacuum run. Confirm the exact thresholds against the PostgreSQL versioning policy and your autovacuum settings for each supported major version.

WAL growth fills disks silently, and the cause is usually outside the primary. The write-ahead log cannot be recycled until it has been archived and no replication slot still needs it. If archive_command starts failing, or a standby or logical replication slot stops consuming, WAL accumulates in pg_wal until the filesystem runs out of space and the primary stops accepting writes. Point-in-time recovery depends on the same archived files, so a silent archiving failure also means your recovery window is shrinking without anyone noticing. Alert on the count of failed archive attempts in pg_stat_archiver, on the age of the last successful archive, on WAL directory size against the volume, and on retained bytes per replication slot. Review how archiving and base backups fit together in the continuous archiving documentation before choosing which signal pages someone.

Severity guidance: page now, ticket, or dashboard only

Page conditions are those where customer-facing service is down or about to fail in a way that cannot wait for business hours. The on-call engineer should act within a short, agreed window, and the alert should say what is broken and where. Keep this tier small. Every page that turns out to be noise trains responders to ignore the next one.

  • Primary unreachable: the database does not answer connection checks from the applications or the monitoring probe.
  • Failover needed or failed: the cluster has no writable primary, or the automatic failover tool reports it could not promote a standby.
  • Transaction ID age near the wraparound limit: the age has crossed a level where autovacuum is not catching up and the database could stop accepting writes.
  • Disk or WAL volume about to fill: free space is low enough that the database will halt writes within the time an engineer needs to respond.
  • Archiving failing with no recovery path: WAL archiving has stopped, so point-in-time recovery is no longer possible for the period.

Set these thresholds from your recovery point objective, recovery time objective and measured workload, and confirm the paging path with the team that will receive the page.

Alert conditions, signals and what to confirm

This table lists each alert condition, what it measures, the signal to watch and what your team must confirm before the alert pages anyone. Read it as a checklist: the signals are fixed by how PostgreSQL reports state, while thresholds, owners and runbooks must come from your own recovery targets and environment.

Alert conditionWhat it measuresSignal to watchWhat to confirm
Primary or instance availabilityWhether each PostgreSQL server accepts connections and answers queriesScrape or probe failure for each instance, plus connection test results from outside the database hostWho is paged, whether a failed probe triggers failover tooling, and the runbook for confirming the primary is really down
Replication lagHow far each standby trails the primary in write, flush and replay positionspg_stat_replication lag columns and standby replay position compared with the primary write positionThreshold tied to your recovery point objective, whether synchronous standbys need a tighter alert, and who acts on a stalled standby
Transaction ID ageHow close each database is to transaction ID wraparound protection limitsAge of the oldest unfrozen transaction ID per database, checked against autovacuum activityWarning and critical levels set from your workload and autovacuum settings, and the owner who investigates a blocked vacuum
Disk space and WAL growthFree space on data and WAL volumes and how fast WAL accumulatesFilesystem free space trend, WAL directory size, and growth rate over a chosen windowAlert lead time that gives your team time to act, the cause checklist for WAL growth, and the on-call owner for storage
Connection saturationHow many sessions are in use compared with the configured maximumActive and total backend counts against max_connections, including pooler client and server connections if PgBouncer is usedThreshold based on observed peak load, whether the pooler sits in front of the database, and the response plan for connection storms
Long-running transactionsTransactions open longer than an agreed time, which can hold back vacuum and locksTransaction start time and state in pg_stat_activity for sessions not idleMaximum acceptable transaction duration per application, exclusions for batch jobs, and who contacts the application owner
Failed WAL archivingWhether the archiver can copy completed WAL segments to the archive destinationArchiver failure counts and last failed WAL name in pg_stat_archiverArchive destination owner, retry expectations, and the runbook for restoring archiving before WAL is removed
Backup age and backup failureTime since the last successful base backup and whether the backup job reported successTimestamp of the last completed backup from your backup tool or job log, plus job exit statusMaximum backup age from your recovery targets, the owner of the backup job, and where the restore test result is recorded

How a PostgreSQL metric becomes a routed alert

The path starts in PostgreSQL's statistics views, which the exporter reads over a least-privilege monitoring role. Prometheus evaluates alert rules against those scraped series and sends firing alerts to Alertmanager, which groups related alerts, applies inhibition and silences, and routes them to on-call or a ticketing queue. Check that every Alertmanager instance receives alerts, and that backup age comes from a separate job, since a backup job that never runs will not show up in these metrics.

Metric flow from PostgreSQL statistics to on-call and ticketing routes.

Building the alert set in order

This sequence turns the alert families into a tested, routed set that your team can review and maintain. Each step produces an artifact or check so you know the alert set works before it wakes anyone up.

  1. Confirm the monitoring role and exporter access

    Start by creating a least-privilege monitoring role on each PostgreSQL instance and confirming that your metrics exporter can read the statistics views the alerts depend on, such as replication status, database activity and archiver status. The DBA or platform engineer who owns the cluster does this, and your security team should review the grants. The step is done when a manual query run as the monitoring role returns values for every view the alert set will use, and a permission error on any of them is treated as a blocker.

  2. Inventory recovery targets and topology

    List every cluster, its primary and standbys, its backup method and archiving destination, and the recovery point and recovery time targets agreed with the business owner. Replication lag thresholds, backup age limits and WAL growth limits all derive from these numbers, so alerts set without them will be guesses. The owner of each system signs off on the inventory. The step is done when every alert threshold you plan to use has a documented source in the inventory, and any missing target is listed as an open question.

  3. Define rules for each alert family

    Write the rules in version control, one group per family: availability, replication lag, transaction ID age, disk and WAL growth, connection saturation, long transactions, failed archiving and backup age. For each rule, record the expression, the threshold source, the evaluation window that avoids flapping, and a short runbook link. The database owner and the on-call lead review the file together. The step is done when every family has at least one rule with a stated reason for its threshold, and the file passes your linter or Prometheus rule check.

  4. Test each rule against a known condition

    For each rule, create the condition in a non-production cluster or a controlled test database. Examples include stopping a standby to raise replication lag, filling a test volume to raise disk use, or holding an open transaction past the threshold. Confirm the alert enters pending, then firing, and then resolves when the condition clears. Record the result for each rule. The step is done when every rule has a recorded test that fired and resolved as expected, and any rule that did not fire is fixed or removed before it reaches production.

  5. Route alerts by severity

    Assign each alert a severity, such as page, ticket or informational, based on whether the condition threatens availability, recovery or only needs attention during working hours. Configure Alertmanager or your existing alert router to send each severity to the right channel, and use grouping and inhibition so one primary failure does not generate a flood of dependent alerts. Alertmanager should be configured with every instance Prometheus points at, as its documentation describes. The step is done when a test notification reaches each route, and an inhibition test confirms that dependent alerts are suppressed during a primary outage.

  6. Confirm alerts reach an accountable owner

    Check that each paging alert has a named owning team, a runbook with the first diagnostic steps, and an escalation path if the owner does not acknowledge it. Confirm the alert stays visible if the monitoring stack itself is down, for example through a separate heartbeat or an external check. The step is done when a walkthrough with the on-call engineers finds no paging alert without an owner or runbook, and the dead-monitor case has been tested once.

  7. Schedule recurring reviews of the alert set

    Set a recurring review of the alert set against the inventory, the recent incident log and the quarterly test results. Remove alerts that fire constantly without action, tighten thresholds that missed real conditions, and re-run the test for any rule whose query or threshold changed. Confirm the review date and owner are recorded in the same repository as the rules. The step is done when the review cadence is written down, the first review is on the calendar, and the last test results are attached to the rules file.

Avoiding alert fatigue and false positives

A PostgreSQL alert set only works if people trust it. The cards below cover the common ways alerting degrades, from alerts nobody can act on to alerts that stop firing when the monitoring host fails, and the Alertmanager features that reduce noise without hiding real faults.

Alerts with no runbook

An alert that does not say what to check or who acts on it trains on-call engineers to ignore it. Each PostgreSQL alert should link to a short runbook that names the first query or command to run, such as checking pg_stat_activity for connection saturation or pg_stat_replication for lag, and the decision that follows. If no action exists, the condition belongs on a dashboard, not a page. Confirm ownership for each alert before go-live.

Thresholds copied from defaults

Default thresholds from exporters, community rule packs or vendor templates reflect someone else's workload. A connection limit or WAL volume that is normal for a reporting database can be an emergency on an order system. Set thresholds from a baseline of your own traffic, record the reasoning in the rule annotation, and review them after the first month of real load. Treat any copied rule as a draft until it has been tested against your instance.

Flapping conditions and the for duration

Metrics such as connection counts, replication lag and long transaction counts can cross a threshold for a few seconds during normal batch work and then recover. Without a for duration in the rule, each crossing sends a new notification. Add a for clause that matches how long the condition must persist before it indicates a fault, and use a longer window for slow-moving signals such as backup age than for availability checks.

Duplicate alerts across primary and replicas

A replication problem, a disk problem on shared storage or a failed archive command can fire the same alert from several PostgreSQL instances at once. Scope rules by role so that lag alerts come from the primary's view of each standby, and availability alerts come from the instance itself. Use consistent labels such as cluster and role, so Alertmanager can group related notifications into one message for the on-call engineer.

Alerts that depend on a failing monitoring host

Prometheus stores data on a single node and is not clustered or replicated by default, so a monitoring host outage can silence every PostgreSQL alert at the moment a database also fails. Run a separate watchdog alert that is always firing and is routed to an external system that pages when it stops, and run Alertmanager as a cluster with Prometheus pointed at each instance. Confirm the path from the database to a human works when the monitoring host is down.

Prometheus storage docs

Grouping and inhibition in Alertmanager

Alertmanager groups related alerts into a single notification, so one incident does not produce a page for every affected database. Inhibition suppresses dependent alerts while a root cause is firing, for example muting replica lag notifications while the primary is unreachable. Silences cover planned maintenance windows. Define the inhibition rules with your team, test them with synthetic alerts, and confirm that suppression never hides an alert that belongs to a different cluster.

Alertmanager docs

Questions teams ask before setting up PostgreSQL alerts

How much effort does a PostgreSQL alert set take to build?

The effort depends mostly on how many databases and environments you run, how many of the alerts already exist in your monitoring stack, and how much of the threshold tuning you do against your own workload. A single cluster with one Prometheus instance and an Alertmanager is a bounded job: you write rules for availability, replication lag, transaction ID age, disk and WAL growth, connection saturation, long transactions, failed archiving and backup age, then tune each threshold against normal behavior. Effort rises with each additional cluster, each extra severity route, and each integration with a paging tool. Ask any partner to show the rule list, the severity mapping and the test plan in the written scope before agreeing a figure.

Can our team set up PostgreSQL alerting on its own?

Yes, if you have an engineer who already runs PostgreSQL and Prometheus and can dedicate time to tuning thresholds. Prometheus is open source under the Apache-2.0 license, so the tools themselves are available to any team. The harder parts are knowing which conditions matter for your recovery targets, avoiding alert noise, and proving that each alert fires when it should. Teams without that PostgreSQL depth often use a partner for the initial rule design and validation, then keep the rules in their own repository. DeployOpen implements and documents this kind of setup inside your infrastructure, and the split of work is agreed in writing before the work starts.

What do we need to provide before the work starts?

You need to provide access and decisions. Access means a monitoring role on each PostgreSQL server, a Prometheus environment you control, and a route for notifications. Decisions include your recovery point objective (RPO) and recovery time objective (RTO), because replication lag and backup age thresholds should follow from them, and your on-call rota, because severity levels only help if someone is accountable for each one. Also confirm who receives warnings versus pages, which change windows suppress alerts, and where the rules will live. Missing RPO and RTO targets are the most common reason thresholds end up arbitrary.

How long does it take to validate the alerts?

Validation takes longer than most teams expect because each alert needs a controlled test that shows it fires, routes to the right person and clears on recovery. Duration depends on the number of alerts, the number of environments, and whether you can run failure tests such as a stopped standby, a paused archive command or an artificially long transaction in a non-production cluster. Ask for the test plan and the list of alerts that cannot be tested safely in production, and confirm with your own change process how those are handled. The validation window is also shaped by your on-call schedule, since you want a period of observed alert behavior before you rely on the thresholds.

Does Prometheus have a licensing cost?

Prometheus itself has no license fee. It is licensed under Apache-2.0 according to its GitHub repository, and the project does not offer a paid enterprise edition. Your costs come from the infrastructure that runs Prometheus and Alertmanager, the storage that holds metrics, the implementation work, and the staff who operate it. Storage is the cost to watch: Prometheus keeps local data for 15 days by default, configurable by time or size, and its local storage is not clustered or replicated. If you need longer retention, you will plan remote write to external storage, which adds its own infrastructure and licensing terms to review.

What recurring work comes after the alerts go live?

Alert rules need ongoing care. Prometheus publishes a new minor release cycle every 6 weeks, and a minor release generally stops receiving bug fixes after those 6 weeks, so you need a plan for upgrades. Long-term support releases receive bug fixes for one year, and the current LTS line is 3.13, supported until July 31, 2027. PostgreSQL itself also changes: supported major versions end on fixed dates, so thresholds for transaction ID age or replication behavior may need review after upgrades. Budget for periodic rule review, threshold tuning after workload changes, and an upgrade window for Prometheus and Alertmanager. Ask any partner whether this is covered by a one-time scope or a retainer.

Which alerts should page someone at night?

Page only for conditions that need action before business hours, such as the primary being unreachable, transaction ID age approaching the point where autovacuum must act urgently, WAL or disk growth that will fill a volume soon, or failed archiving that stops point-in-time recovery from working. Send slower issues, such as moderate replication lag or a backup that is a day older than usual, to a warning channel reviewed in working hours. Alertmanager groups and inhibits related alerts, so a single outage does not generate dozens of pages. Confirm the exact thresholds against your RPO and RTO and your own workload rather than copying values from another environment.

What to confirm in your environment

Start by confirming which PostgreSQL major version you run, because the alert set depends on it. The versioning policy lists 18, 17, 16, 15 and 14 as supported, with 14 ending November 12, 2026, and 13 and earlier unsupported. Check the PostgreSQL versioning policy against your own upgrade plan. A cluster on an unsupported major version still needs these alerts, but the upgrade decision should be made before you tune thresholds for it, since a major upgrade may change the views and statistics your queries rely on.

Next, confirm who owns failover. PostgreSQL does not detect a failed primary or promote a standby on its own, so an alert on primary unavailability only helps if an external tool or runbook acts on it. Ask whether your cluster uses an automated failover tool, a manual runbook, or a managed service, and whether the alert that fires is routed to the team that can promote a standby. Also confirm whether your standbys are synchronous or asynchronous, because that changes what replication lag means for your recovery point targets.

Finally, confirm the monitoring stack and exporter path before writing rules. Check whether you collect metrics with a Prometheus exporter, the OpenTelemetry Collector, Zabbix or another tool, and whether the monitoring role can read the statistics views each alert uses. Confirm where alerts are evaluated and who receives them, including whether your backup tool exposes archive and backup age in a form you can alert on. Record the answers in the same change record as your thresholds, so a version upgrade, a new exporter or a failover change triggers a review of the rules.

How DeployOpen scopes and delivers PostgreSQL alerting

DeployOpen plans PostgreSQL alerting as part of the database build, not as an afterthought. We agree which conditions page someone, which only open a ticket, and which feed dashboards, then build and document the rules in infrastructure you control.

How we scope

  • Inventory the PostgreSQL topology, replicas, backup tooling and monitoring stack already in use before choosing alert conditions.
  • Agree a written severity model that maps each alert to an owner, a response expectation and an escalation path.
  • Confirm thresholds with your recovery point and recovery time targets, so replication lag and backup age alerts match what your business accepts.

How we build

  • Write alert rules for availability, replication lag, transaction ID age, disk and WAL growth, connection saturation and long transactions.
  • Configure alert routing, grouping and silences in your alerting pipeline, and test each rule against a controlled condition before it goes live.
  • Set up least-privilege monitoring access so alert queries read statistics without granting write or superuser rights.

How we hand over

  • Deliver a runbook for each alert describing likely causes, first checks and the escalation step that resolves it.
  • Document threshold rationale, so your team can tune noise later without losing the conditions that protect data.
  • Walk your operations staff through test alerts and the review process used to retire or adjust rules.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer, covering rule reviews after PostgreSQL version changes.
  • Agree in writing who reviews alert volume, how often, and who approves threshold changes after go-live.
  • Ask any provider to confirm how alert rules are versioned and whether they are kept in your own source control.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.