From 413c1c7fc1a2954eca448a0c78de1272f3029609 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 2 Mar 2021 18:24:22 +0000 Subject: [PATCH] Add monitoring for unfrozen IDs in postgres databases --- .../templates/default/postgres_queries.yml.erb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cookbooks/postgresql/templates/default/postgres_queries.yml.erb b/cookbooks/postgresql/templates/default/postgres_queries.yml.erb index c2fc048c8..f513b33e7 100644 --- a/cookbooks/postgresql/templates/default/postgres_queries.yml.erb +++ b/cookbooks/postgresql/templates/default/postgres_queries.yml.erb @@ -137,3 +137,16 @@ pg_database: - size_bytes: usage: "GAUGE" description: "Disk space used by the database" + +pg_unfrozen_ids: + query: "SELECT current_database() AS datname, max(age(relfrozenxid)) AS xid_age, max(mxid_age(relminmxid)) AS mxid_age FROM pg_class WHERE relkind IN ('r', 'm')" + metrics: + - datname: + usage: "LABEL" + description: "Name of the database" + - xid_age: + usage: "GAUGE" + description: "Age of the oldest unfrozen transaction ID in this database" + - mxid_age: + usage: "GAUGE" + description: "Age of the oldest unfrozen multixact ID in this database" -- 2.39.5