stat_wal_receiver collector monitors WAL (Write-Ahead Log) receiver statistics on standby servers.
Status
Default: Disabled Enable with:--collector.stat-wal-receiver
This collector only returns data on standby/replica servers. It will have no output on primary servers.
Metrics
pg_stat_wal_receiver_receive_start_lsn
Type: CounterDescription: First write-ahead log location used when WAL receiver is started (as decimal) Labels:
upstream_host- Host name of the upstream serverslot_name- Replication slot namestatus- WAL receiver status
pg_stat_wal_receiver_receive_start_tli
Type: GaugeDescription: First timeline number used when WAL receiver is started Labels:
upstream_host, slot_name, status
pg_stat_wal_receiver_flushed_lsn
Type: CounterDescription: Last write-ahead log location already received and flushed to disk (as decimal) Labels:
upstream_host, slot_name, status
Availability: PostgreSQL 9.6+
pg_stat_wal_receiver_received_tli
Type: GaugeDescription: Timeline number of last write-ahead log location received and flushed to disk Labels:
upstream_host, slot_name, status
pg_stat_wal_receiver_last_msg_send_time
Type: CounterDescription: Send time of last message received from origin WAL sender (Unix timestamp) Labels:
upstream_host, slot_name, status
pg_stat_wal_receiver_last_msg_receipt_time
Type: CounterDescription: Receipt time of last message received from origin WAL sender (Unix timestamp) Labels:
upstream_host, slot_name, status
pg_stat_wal_receiver_latest_end_lsn
Type: CounterDescription: Last write-ahead log location reported to origin WAL sender (as decimal) Labels:
upstream_host, slot_name, status
pg_stat_wal_receiver_latest_end_time
Type: CounterDescription: Time of last write-ahead log location reported to origin WAL sender (Unix timestamp) Labels:
upstream_host, slot_name, status
pg_stat_wal_receiver_upstream_node
Type: GaugeDescription: Node ID of the upstream node (extracted from slot name pattern
repmgr_slot_N)
Labels: upstream_host, slot_name, status
SQL Queries
Check for flushed_lsn column:PostgreSQL Versions
Supported: PostgreSQL 9.6+ Version-specific features:- PostgreSQL 9.6+:
flushed_lsncolumn added - PostgreSQL 10+: Function names changed from
pg_*_xlog_*topg_*_wal_*
Required Permissions
The monitoring user needs:- Access to
pg_catalog.pg_stat_wal_receiverview
Example Output
Use Cases
Monitor Replication Lag
Detect Replication Issues
Network Latency
Status Values
streaming- Actively receiving WAL from primarystopped- WAL receiver stoppedstarting- WAL receiver starting upwaiting- Waiting to connect to primaryrestarting- Restarting after connection loss
Alert Examples
Troubleshooting
Check WAL Receiver Status
Common Issues
-
Status: stopped
- Check replication configuration
- Verify network connectivity to primary
- Check
primary_conninfoinrecovery.conf/postgresql.auto.conf
-
No data returned
- Collector only works on standby servers
- Check
SELECT pg_is_in_recovery();returnstrue
-
High message latency
- Network issues between primary and replica
- High load on primary
- Check
wal_sender_timeoutandwal_receiver_timeout