From e65e14f9b2445b3ca615feb6badc9991f720ac53 Mon Sep 17 00:00:00 2001 From: "andres.suarez" Date: Tue, 18 Aug 2026 14:38:38 +0200 Subject: [PATCH 1/2] feat: add transaction ID age to postgres_exporter Add pg_wraparound custom metric to postgres_exporter that tracks the maximum transaction ID age across all databases. This enables proactive monitoring of wraparound risk before it reaches critical thresholds. - New queries.yml with max(age(datfrozenxid)) query - Deployed to /opt/postgres_exporter/ via Ansible Related: INDATA-1261 --- ansible/files/queries.yml | 9 +++++++++ ansible/tasks/internal/postgres-exporter.yml | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 ansible/files/queries.yml diff --git a/ansible/files/queries.yml b/ansible/files/queries.yml new file mode 100644 index 000000000..6a56f9f5a --- /dev/null +++ b/ansible/files/queries.yml @@ -0,0 +1,9 @@ +pg_wraparound: + query: | + SELECT + max(age(datfrozenxid)) AS max_transaction_id_age + FROM pg_database + metrics: + - max_transaction_id_age: + usage: GAUGE + description: "Max transaction ID age (wraparound risk) across databases" diff --git a/ansible/tasks/internal/postgres-exporter.yml b/ansible/tasks/internal/postgres-exporter.yml index 03b16474a..5d876cfe0 100644 --- a/ansible/tasks/internal/postgres-exporter.yml +++ b/ansible/tasks/internal/postgres-exporter.yml @@ -39,6 +39,15 @@ extra_opts: [--strip-components=1] become: yes +- name: deploy queries.yml for custom metrics + copy: + src: files/queries.yml + dest: /opt/postgres_exporter/queries.yml + owner: root + group: root + mode: '0644' + become: yes + - name: exporter create a service template: src: files/postgres_exporter.service.j2 From 801c69c09c42502fa6e2bb348c663ff6903881b2 Mon Sep 17 00:00:00 2001 From: andres suarez Date: Tue, 18 Aug 2026 15:29:57 +0200 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- ansible/files/queries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/files/queries.yml b/ansible/files/queries.yml index 6a56f9f5a..43024c3de 100644 --- a/ansible/files/queries.yml +++ b/ansible/files/queries.yml @@ -6,4 +6,4 @@ pg_wraparound: metrics: - max_transaction_id_age: usage: GAUGE - description: "Max transaction ID age (wraparound risk) across databases" + description: "Max transaction ID age (in XIDs; wraparound risk) across databases"