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_exhaustion query to templates/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:

  1. Checks if the user has necessary permissions (pg_read_server_files role or superuser)
  2. Verifies required functions (pg_ls_dir, pg_stat_file) are available
  3. Scans the pg_multixact/members directory and sums file sizes
  4. 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.

Merge request reports

Loading