Draft: Add monitoring for PostgreSQL multixact members space exhaustion
Adds a new PostgreSQL exporter query to monitor the size of the pg_multixact/members directory, which can cause database issues when space exhaustion occurs.
Changes
- Added
pg_members_space_exhaustionquery totemplates/postgres_exporter/queries.yaml.erb - Uses PostgreSQL file system functions (
pg_ls_dir,pg_stat_file) to scan the multixact members directory and calculate total size - Includes permission checks to ensure safe execution
Metrics Exported
-
multixact_members_bytes(GAUGE): The total size of the multixact members directory in bytes -
status_code(GAUGE): Query execution status (0 = OK, 1 = NO ACCESS, 2 = NO PERMISSION)
Implementation Details
The query:
- Checks if the user has necessary permissions (
pg_read_server_filesrole or superuser) - Verifies required functions (
pg_ls_dir,pg_stat_file) are available - Scans the
pg_multixact/membersdirectory and sums file sizes - Returns metrics with appropriate status codes for error handling
This enables proactive monitoring and alerting for multixact members space exhaustion issues before they impact database operations.