Browse Source

Add metric for max postgresql transaction ID age

I've been reading a little about PostgreSQL transaction ID wraparound
today, and how it's knocked multiple companies out of commission for
days to get it resolved. It should have almost no chance of happening on
Tildes for years, but this will let me set up some monitoring for it
now, while I'm thinking about it.

For more info:
https://blog.sentry.io/2015/07/23/transaction-id-wraparound-in-postgres.html
merge-requests/55/head
Deimos 6 years ago
parent
commit
2d422bd027
  1. 7
      salt/salt/prometheus/exporters/postgres_exporter.sls
  2. 1
      salt/salt/prometheus/exporters/prometheus_postgres_exporter.service
  3. 6
      salt/salt/prometheus/exporters/queries.yaml

7
salt/salt/prometheus/exporters/postgres_exporter.sls

@ -16,6 +16,13 @@ unpack-postgres-exporter:
- options: --strip-components=1 - options: --strip-components=1
- enforce_toplevel: False - enforce_toplevel: False
/opt/prometheus_postgres_exporter/queries.yaml:
file.managed:
- source: salt://prometheus/exporters/queries.yaml
- user: postgres
- group: postgres
- mode: 644
/etc/systemd/system/prometheus_postgres_exporter.service: /etc/systemd/system/prometheus_postgres_exporter.service:
file.managed: file.managed:
- source: salt://prometheus/exporters/prometheus_postgres_exporter.service - source: salt://prometheus/exporters/prometheus_postgres_exporter.service

1
salt/salt/prometheus/exporters/prometheus_postgres_exporter.service

@ -9,6 +9,7 @@ WorkingDirectory=/opt/prometheus_postgres_exporter
User=postgres User=postgres
Group=postgres Group=postgres
Environment="DATA_SOURCE_NAME=user=postgres host=/run/postgresql/ sslmode=disable" Environment="DATA_SOURCE_NAME=user=postgres host=/run/postgresql/ sslmode=disable"
Environment="PG_EXPORTER_EXTEND_QUERY_PATH=/opt/prometheus_postgres_exporter/queries.yaml"
ExecStart=/opt/prometheus_postgres_exporter/postgres_exporter ExecStart=/opt/prometheus_postgres_exporter/postgres_exporter
[Install] [Install]

6
salt/salt/prometheus/exporters/queries.yaml

@ -0,0 +1,6 @@
pg_txid:
query: "SELECT max(age(datfrozenxid)) AS max_txid_age from pg_database"
metrics:
- max_txid_age:
usage: "GAUGE"
description: "Highest transaction ID age (wraparound at 2 billion)"
Loading…
Cancel
Save