Custom Alert - PostgreSQL user role expires in N days


As a PostgreSQL administrator, you may be responsible for creating user accounts and groups. You may also be responsible for granting and revoking privileges.  The alert will notify you when a user role is about to expire in N days. 

Alert Definition

To create the alert, click on Alerts > Manage Alerts tab and create a Custom Alert of type Custom SQL Alert - Multiple Numeric Return. Configure the alert with values similar to these:

Alert Name: User role expires in N days

Execution Interval: 1 days

Notification Text: Empty

SQL Statement:

select rolname, EXTRACT(DAYS FROM now()-rolvaliduntil) from pg_roles WHERE rolvaliduntil is not null

Execute Against: Monitored Instance

Units: Days

High Threshold: Min 2, Max 15