You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: no metric for role password expiry (VALID UNTIL) #11459
Managed roles and DatabaseRole accept validUntil, but nothing exposes the resulting expiry. Neither the predefined cnpg_collector_* metrics nor the default query sets in config/manager/default-monitoring.yaml (backends, pg_database, pg_stat_*, pg_settings, pg_extensions and the rest) touch roles at all.
That makes an expiring password invisible until it bites. Expiry behaves like login: false in one important way: open sessions keep working, so nothing breaks at the moment the password lapses, and the failure surfaces later at the first reconnect, when the connection is refused (same trait discussed in #11382).
What already works
A custom query covers it and needs no extra grants. The exporter connects as cnpg_metrics_exporter, which is not a superuser, and pg_roles exposes rolvaliduntil to it, so pg_authid is not needed:
role_expiry:
query: | SELECT rolname AS role, extract(epoch from rolvaliduntil) AS valid_until_seconds FROM pg_roles WHERE rolcanlogin AND rolvaliduntil IS NOT NULL AND rolvaliduntil <> 'infinity'metrics:
- role:
usage: "LABEL"description: "Role"
- valid_until_seconds:
usage: "GAUGE"description: "Password expiry as a unix timestamp"
Verified on an operator 1.30 cluster: pointing spec.monitoring.customQueriesConfigMap at this ConfigMap alongside the default one produces the metric without restarting the pod, and cnpg_collector_last_collection_error stays at 0.
Ask
Either ship it as a default query, where the cost stays near zero because roles with an expiry are rare and the filter drops everything else, or document the recipe in monitoring.md next to the custom queries section. I can send either PR.
Activity
gbartolini commentedon Sep 11, 2026
Hi @melancholictheory! Would you like to propose a patch for this? I would add it to the config map. Thanks!
melancholictheory commentedon Sep 11, 2026
Hi @gbartolini, thanks for the quick reply. I'd like to work on this