postgresql.wal.age
Oldest WAL file ageInterface Metrics (2)
About this metric
The postgresql.wal.age metric measures the age in seconds of the oldest Write-Ahead Logging (WAL) file in the PostgreSQL database system. Write-Ahead Logging is a fundamental component of PostgreSQL's durability and crash recovery mechanism, where all changes are first written to WAL files before being applied to data files. This metric serves as a critical indicator of WAL management health, revealing how long the oldest WAL segment has existed in the system. An increasing age typically indicates that WAL files are not being archived or cleaned up properly, which can result from misconfigured archiving, replication lag from standby servers, or stalled replication slots that prevent WAL segments from being recycled.
From an operational perspective, monitoring this metric is essential for maintaining system reliability and preventing disk space exhaustion. When WAL files accumulate due to replication delays, failed archive commands, or abandoned replication slots, the pg_wal directory can grow unbounded and consume all available disk space, leading to database outages. Healthy systems typically show WAL ages that align with the wal_keep_size or max_wal_size configuration parameters, usually keeping WAL files for minutes to a few hours under normal operation. Values exceeding several hours or days warrant immediate investigation, particularly in environments with replication or point-in-time recovery requirements.
Common alerting thresholds should be established based on expected archival and replication patterns, with warnings triggered when WAL age exceeds 3-6 hours and critical alerts when approaching 12-24 hours, adjusted for specific operational requirements. During troubleshooting, elevated WAL age often points to specific issues: disconnected or severely lagging replicas holding back WAL recycling, failed archive commands that prevent segments from being removed, or inactive replication slots that indefinitely retain WAL files. Operators should correlate this metric with replication lag metrics, pg_stat_archiver statistics, and disk usage monitoring to identify the root cause and prevent potential service disruptions.
Available Content
Understanding PostgreSQL WAL age is critical for maintaining database health and preventing catastrophic failures like transaction ID wraparound. When WAL segments accumulate or transaction IDs approach their limits, your database can grind to a halt or even refuse connections entirely. Our curated knowledge base connects the dots between monitoring postgresql.wal.age and the operational practices that keep your system running smoothly.
We've assembled expert guidance on managing transaction ID exhaustion and fine-tuning autovacuum settings—two critical areas that directly impact WAL age metrics. Learn how to interpret warning signs before they become emergencies, understand the relationship between autovacuum configuration and transaction ID consumption, and discover battle-tested approaches from PostgreSQL experts who've navigated these challenges in production environments. Don't wait for a wraparound crisis to understand these interconnected systems—get ahead of potential issues with actionable insights tailored specifically to this metric.