/**
 * View to monitor write ahead log (WAL) archiving
 *
 * @author: "Stefanie Janine Stölting"<stefanie@proopensource.eu>
 * @license: PostgreSQL https://opensource.org/licenses/postgresql
 */

CREATE OR REPLACE VIEW monitoring_wal_archiving AS
SELECT psa.archived_count
	, psa.failed_count
	, psa.last_archived_time
	, psa.last_archived_wal
	, psa.last_failed_time
	, psa.last_failed_wal
	, psa.stats_reset
FROM pg_catalog.pg_stat_archiver AS psa
;

COMMENT ON VIEW monitoring_wal_archiving IS 'View to monitor write ahead log (WAL) archiving.';
COMMENT ON COLUMN monitoring_wal_archiving.archived_count IS 'The number of WAL files that have been successfully archived.';
COMMENT ON COLUMN monitoring_wal_archiving.failed_count IS 'The number of failed attempts for archiving WAL files.';
COMMENT ON COLUMN monitoring_wal_archiving.last_archived_time IS 'Last time WAL files have been archived.';
COMMENT ON COLUMN monitoring_wal_archiving.last_archived_wal IS 'The name of the WAL file most recently successfully archived.';
COMMENT ON COLUMN monitoring_wal_archiving.last_failed_time IS 'The last time WAL files failed to be archived.';
COMMENT ON COLUMN monitoring_wal_archiving.last_failed_wal IS 'The name of the WAL file that most recently failed to get archived.';
COMMENT ON COLUMN monitoring_wal_archiving.stats_reset IS 'The last time the WAL statistics have been reset.';
