Usage
General Flags
Show context-sensitive help. Also try
--help-long and --help-man for detailed documentation.Short: -hShow application version and build information.
Print the internal representation of metric maps and exit. Useful for debugging custom queries. Does not start the exporter.
Configuration File
Path to the YAML configuration file containing auth modules and other settings.Example:
--config.file=/etc/postgres_exporter/config.ymlWeb Server Flags
Address and port to listen on for HTTP requests. Format:
host:port or :portExamples:--web.listen-address=":9187"- Listen on all interfaces, port 9187--web.listen-address="127.0.0.1:9187"- Listen only on localhost--web.listen-address="0.0.0.0:8080"- Listen on all interfaces, port 8080
HTTP path where metrics are exposed.Environment Variable:
PG_EXPORTER_WEB_TELEMETRY_PATHExample: --web.telemetry-path="/custom/metrics"Path to configuration file for TLS and/or basic authentication. See exporter-toolkit documentation for format details.Example:
--web.config.file=/etc/postgres_exporter/web-config.ymlUse systemd socket activation listeners instead of port listeners. Linux only.Example:
--web.systemd-socketMetrics Collection Flags
Disable all built-in metrics. When enabled, only metrics from
--extend.query-path are exported. Useful for monitoring non-standard PostgreSQL variants.Environment Variable: PG_EXPORTER_DISABLE_DEFAULT_METRICSExample: --disable-default-metricsDisable scraping of
pg_settings metrics.Environment Variable: PG_EXPORTER_DISABLE_SETTINGS_METRICSExample: --disable-settings-metricsPrefix for all exported metrics. Change to avoid conflicts when running multiple exporters.Environment Variable:
PG_EXPORTER_METRIC_PREFIXExample: --metric-prefix=postgresResults in metrics like postgres_up, postgres_stat_database_*, etc.Timeout for collecting statistics from PostgreSQL. Prevents connection pool exhaustion when queries are slow. Must be > 1ms.Environment Variable:
PG_EXPORTER_COLLECTION_TIMEOUTExamples: 30s, 2m, 500msCollector Flags
Collectors can be individually enabled or disabled. Use[no-] prefix to explicitly disable.
Database Collectors
Enable the database collector. Exports
pg_database metrics including database size and statistics.Enable the database wraparound collector. Monitors transaction ID wraparound risk.
Lock Collectors
Enable the locks collector. Exports lock wait statistics.
Transaction Collectors
Enable the long running transactions collector. Identifies transactions exceeding a threshold.
Process Collectors
Enable the postmaster collector. Exports postmaster process information.
Enable the process idle collector. Monitors idle connections.
Replication Collectors
Enable the replication collector. Monitors streaming replication status.
Enable the replication slot collector. Monitors replication slot lag.
Statistics Collectors
Enable the stat activity autovacuum collector. Monitors autovacuum processes.
Enable the stat bgwriter collector. Exports background writer statistics.
Enable the stat checkpointer collector (PostgreSQL 17+). Exports checkpoint statistics.
Enable the stat database collector. Exports
pg_stat_database metrics.Enable the stat progress vacuum collector. Monitors vacuum progress.
Enable the stat user tables collector. Exports
pg_stat_user_tables metrics.Enable the stat WAL receiver collector. Monitors WAL receiver on replicas.
Enable the statio user indexes collector. Exports I/O statistics for indexes.
Enable the statio user tables collector. Exports I/O statistics for tables.
WAL Collectors
Enable the WAL collector. Monitors write-ahead log statistics.
Enable the xlog location collector (older PostgreSQL versions). Monitors WAL position.
pg_stat_statements Collector
Enable the stat statements collector. Requires
pg_stat_statements extension. Exports query execution statistics.Include the full query text with queryid in
pg_stat_statements metrics.Maximum length of statement text to include in metrics (when
include_query is enabled).Example: --collector.stat_statements.query_length=200Maximum number of statements to return from
pg_stat_statements.Example: --collector.stat_statements.limit=500Comma-separated list of database names to exclude from
pg_stat_statements metrics.Example: --collector.stat_statements.exclude_databases=template0,template1Comma-separated list of user names to exclude from
pg_stat_statements metrics.Example: --collector.stat_statements.exclude_users=postgres,adminDeprecated Flags
DEPRECATED: Automatically discover and monitor all databases on the server.Environment Variable:
PG_EXPORTER_AUTO_DISCOVER_DATABASESReplacement: Use Prometheus service discovery insteadDEPRECATED: Comma-separated list of databases to exclude when
--auto-discover-databases is enabled.Environment Variable: PG_EXPORTER_EXCLUDE_DATABASESDEPRECATED: Comma-separated list of databases to exclusively monitor when
--auto-discover-databases is enabled.Environment Variable: PG_EXPORTER_INCLUDE_DATABASESDEPRECATED: Path to YAML file containing custom queries.Environment Variable:
PG_EXPORTER_EXTEND_QUERY_PATHReplacement: Use built-in collectors or sql_exporterDEPRECATED: Comma-separated list of
label=value pairs to add to all metrics.Environment Variable: PG_EXPORTER_CONSTANT_LABELSExample: --constantLabels=environment=prod,region=us-eastLogging Flags
Set logging verbosity level.Options:
debug, info, warn, errorExample: --log.level=debugSet the log output format.Options:
logfmt, jsonExample: --log.format=jsonConfiguration Examples
- Basic Monitoring
- Minimal Collectors
- Query Performance
- Replication Monitoring
- Security Hardened
- Custom Prefix
Combining with Environment Variables
Flags override environment variables:Checking Current Configuration
View the active configuration by checking the landing page:Next Steps
Environment Variables
See equivalent environment variables for containerized deployments
Collectors Reference
Learn what each collector monitors