Skip to content

[Task] Add account expiry monitoring metrics for PostgreSQL#4040

Open
turanalmammadov wants to merge 1 commit intoapache:masterfrom
turanalmammadov:feat/add-postgresql-account-expiry-monitoring
Open

[Task] Add account expiry monitoring metrics for PostgreSQL#4040
turanalmammadov wants to merge 1 commit intoapache:masterfrom
turanalmammadov:feat/add-postgresql-account-expiry-monitoring

Conversation

@turanalmammadov
Copy link
Contributor

What does this PR do?

Adds account expiry monitoring metrics for PostgreSQL, consistent with the pattern already used for Oracle, MariaDB, SQL Server, and TiDB.

Changes

  • app-postgresql.yml: Added new account_expiry metric set that queries pg_roles for roles with a non-null rolvaliduntil value. Exposes:

    • rolname – role (user) name
    • rolvaliduntil – account expiration timestamp
    • seconds_until_expiry – seconds remaining until expiry (negative means already expired)
    • rolcanlogin – whether the role is permitted to log in
  • home/docs/help/postgresql.md: Added account_expiry metric set table (English)

  • home/i18n/zh-cn/.../postgresql.md: Added account_expiry metric set table (Chinese)

Why is this needed?

Monitoring password/account expiration helps DBAs proactively detect accounts about to expire and avoid unexpected authentication failures in production systems.

Testing

SQL query tested against PostgreSQL 14+:

SELECT rolname, rolvaliduntil::text as rolvaliduntil,
       EXTRACT(EPOCH FROM (rolvaliduntil - now()))::bigint AS seconds_until_expiry,
       rolcanlogin::text as rolcanlogin
FROM pg_roles
WHERE rolvaliduntil IS NOT NULL
ORDER BY rolvaliduntil ASC;

Made with Cursor

- Add account_expiry metric set to app-postgresql.yml querying pg_roles
  for roles with non-null rolvaliduntil (expiration timestamp)
- Expose: rolname, rolvaliduntil, seconds_until_expiry, rolcanlogin
- Update docs: home/docs/help/postgresql.md (English)
- Update docs: home/i18n/zh-cn/.../postgresql.md (Chinese)

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions bot added doc Improvements or additions to documentation monitoring-template backend labels Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend doc Improvements or additions to documentation monitoring-template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant