This collector is enabled by default.
What It Monitors
The database collector queries thepg_database system catalog to retrieve:
- Database size in bytes
- Connection limits per database
- List of all databases (excluding those in the exclude list)
Metrics Exposed
pg_database_size_bytes
Disk space used by each database in bytes. Type: GaugeLabels:
datname- Database name
pg_database_connection_limit
Connection limit set for each database. A value of -1 indicates no limit. Type: GaugeLabels:
datname- Database name
SQL Queries Used
The collector executes the following queries:Configuration
Enable/Disable the Collector
Exclude Databases
You can exclude specific databases from metrics collection:The exclusion filter is applied in the collector code, not in the SQL query, to avoid complex parameterized queries.
Use Cases
Monitor Database Growth
Track database size over time to plan capacity:Alert on Connection Limit Approaching
Create alerts when active connections approach the database limit:Identify Largest Databases
Find which databases consume the most disk space:Permissions Required
The database collector requires:CONNECTprivilege on the PostgreSQL instance- Access to the
pg_databasesystem catalog (granted by default) - For PostgreSQL 10+: No special permissions needed
- For PostgreSQL <10: Read access to system catalogs
Performance Considerations
The collector queries each database individually usingpg_database_size(), which:
- Is generally fast for small to medium databases
- May take longer for very large databases (100GB+)
- Does not lock tables or interfere with normal operations
- Can be excluded from collection if causing performance issues