How Collectors Work
When the exporter scrapes metrics from PostgreSQL:- Each enabled collector queries PostgreSQL system views or functions
- The collector transforms the query results into Prometheus metrics
- Metrics are exposed at the
/metricsendpoint - Collectors run concurrently for efficient data collection
pg_ by default and include relevant labels for filtering and aggregation.
Collector States
Each collector can be in one of two states:- Enabled by default - The collector runs automatically unless explicitly disabled
- Disabled by default - The collector must be explicitly enabled to run
Enabling and Disabling Collectors
Collectors are controlled using command-line flags with the format--collector.<name> or --no-collector.<name>.
Enable a collector
Disable a collector
Using environment variables
You can also control collectors through environment variables, though command-line flags take precedence:Available Collectors
The following collectors are available in the PostgreSQL Server Exporter:Core Database Collectors
- Database - Database size and connection limits
- Locks - Lock counts by database and mode
- Replication - Replication lag and status
- WAL - Write-Ahead Log segments and size
Statistics Collectors
- Database Statistics - Transaction, block, and tuple statistics per database
- User Tables Statistics - Table-level access, modification, and maintenance statistics
Deprecated Features
Collector Performance
Each collector execution is tracked with the following metrics:pg_scrape_collector_duration_seconds- Time taken to execute the collectorpg_scrape_collector_success- Whether the collector succeeded (1) or failed (0)
Collection Timeout
You can set a global timeout for all collectors using the--collection.timeout flag:
The default collection timeout is 1 minute. Set this value based on your database size and query complexity.