monitoring_role
monitoring_role · Security-definer monitoring wrappers for a non-privileged role
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100421 | monitoring_role | monitoring_role | 0.0.1 | STAT | WTFPL | SQL |
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
monitoring_role creates narrowly wrapped monitoring functions that a superuser can grant to an otherwise unprivileged role. The wrappers run with definer rights, so the extension should be installed and delegated only by a trusted administrator.
Core Workflow
Install it into a dedicated schema, grant a monitoring login access through the helper, and put that schema before pg_catalog in the login’s search path.
After reconnecting as the delegated role, unqualified monitoring calls resolve to the wrappers.
Exposed Objects and Boundaries
pg_stat_activity()and the matching view expose the complete activity view.pg_ls_dir(text)andpg_stat_file(text)wrap the corresponding catalog functions.- Both
pg_read_fileoverloads accept only the literal pathPG_VERSION; other paths raise an exception. grant_monitor(text)grants schema usage, view selection, and execution on the wrappers.
Creating version 0.0.1 requires superuser rights. Execution is revoked from public by the installation script, but grant_monitor(text) itself is not a security-definer function; run it as the extension owner or another role able to issue the grants. Review the exposed directory and activity information against your security policy before delegation.