canonical / canonical/postgresql-operator

PostgreSQL Exporter dead metrics

Open
#1,567 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
20
Forks
36
Avg merge
4d 15h
Merged PRs (30d)
30

Description

## Steps to reproduce
1. Deploy the charm.

## Expected behaviour
All PostgreSQL alerts evaluate correctly, and the `PostgresqlRestarted` alert has access to the postmaster start time metrics.

## Actual behaviour
Several alerts are dead because the underlying metrics no longer exist natively in the exporter.
* `PostgresqlHighRateDeadlock` (missing `postgresql_errors_total`)
* `PostgresqlSslCompressionActive` (missing `pg_stat_ssl_compression`)
* `PostgresqlRestarted` (fails because `--collector.postmaster` is not enabled in `start-exporter.sh`).
* Custom injecting SQL via `queries.yaml` file to expose the necessary pg_txid_* and pg_bloat_* metrics is required:
* `PostgresqlLowXidConsumption`
* `PostgresqlBloatIndexHigh`
* `PostgresqlBloatTableHigh`
* `PostgresqlInvalidIndex`

## Versions

Juju CLI: N/A
Juju agent: N/A
Charm revision: N/A
LXD: N/A

## Log output
Juju debug log: N/A

## Additional context
**Proposals for Discussion:**
1. **Enable Postmaster Collector**: Update `start-exporter.sh` to include `EXPORTER_OPTS="--collector.postmaster"` so `PostgresqlRestarted` works.
2. **Dead Alerts**: Remove `PostgresqlHighRateDeadlock` and `PostgresqlSslCompressionActive` as they cannot be exported natively anymore.
3. **Custom Queries (`queries.yaml`)**:
* Maybe inject the custom query *only* for `PostgresqlInvalidIndex` as it is relatively lightweight.
* **Question for maintainers**: Does it make sense to include the heavier custom queries required for `PostgresqlLowXidConsumption`, `PostgresqlBloatIndexHigh(>80%)`, and `PostgresqlBloatTableHigh(>80%)`? Given that the exporter is scraped every ~20 seconds, running these heavy bloat/xid queries frequently could negatively impact database performance.

Reference: https://github.com/samber/awesome-prometheus-alerts/issues/289#issuecomment-1164842737

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.