Configuration Methods
The exporter supports three primary configuration approaches:Environment Variables
Configure using environment variables for containerized deployments
Command-Line Flags
Use flags for traditional server deployments
Configuration File
Define auth modules and multi-target support via YAML
Configuration File Location
The exporter loads its configuration from a YAML file specified by the--config.file flag. The default location is postgres_exporter.yml in the current working directory.
Precedence Order
When the same setting is configured in multiple places, the following precedence applies (highest to lowest):Environment variables starting with
PG_EXPORTER_ will be overwritten by the corresponding CLI flag if given.Basic Configuration Example
Here’s a minimal configuration to get started:- Environment Variables
- Command-Line Flags
- Docker
Configuration File Structure
The YAML configuration file supports the following top-level sections:auth_modules
Defines authentication modules for multi-target monitoring. See Authentication Modules for details.Quick Start Guides
Data Source Configuration
Configure database connection strings and DSN formats
Environment Variables
Complete reference of all environment variables
Security Considerations
Using File-Based Secrets
For enhanced security, store sensitive values in files:_FILE variants for:
DATA_SOURCE_USER_FILEDATA_SOURCE_PASS_FILEDATA_SOURCE_URI_FILE
When running in a container, the process runs with uid/gid 65534. Ensure file permissions allow this user to read secret files.
Next Steps
Configure Data Source
Set up your PostgreSQL connection
Explore Flags
Browse all available command-line options