The postgres_exporter is a Prometheus exporter written in Go that collects and exposes metrics from PostgreSQL database servers. It enables monitoring of PostgreSQL instances by converting internal database statistics into Prometheus-compatible metrics that can be scraped and visualized in monitoring systems.
The exporter supports PostgreSQL versions 13 through 18 as verified by its CI testing. It is distributed as a Docker container image and can be deployed either as a sidecar alongside individual PostgreSQL instances or as a centralized service using the multi-target pattern. The multi-target functionality, currently in beta, allows a single exporter instance to monitor multiple PostgreSQL targets by accepting HTTP requests to the /probe endpoint with target DSN parameters, making it suitable for monitoring SaaS-managed PostgreSQL services where sidecar deployment is not feasible.
The exporter provides extensive configurability through command-line flags and environment variables. It includes numerous collector modules that can be individually enabled or disabled, covering database statistics, replication status, transaction activity, WAL archiving, background writer statistics, table and index I/O metrics, and statement-level query statistics. Key collectors enabled by default include database metrics, locks, replication, replication slots, settings, statement activity, archiver statistics, background writer metrics, database statistics, vacuum progress, replication statistics, and user table statistics. Optional collectors disabled by default include database wraparound detection, long-running transaction tracking, postmaster metrics, idle process detection, autovacuum activity, checkpoint statistics, WAL receiver status, index I/O metrics, WAL metrics, and xlog location tracking.
Configuration is managed through a YAML file that supports auth_modules for defining preset authentication credentials, allowing sensitive connection information to be kept out of URLs when using the multi-target endpoint. The exporter accepts data source configuration through multiple environment variables including DATA_SOURCE_NAME, DATA_SOURCE_URI, and file-based variants for usernames and passwords, supporting secure credential management through mounted files rather than environment variables.
According to GitGenius activity tracking, the repository has experienced significant community engagement with 133 tracked issues and pull requests. The median response latency for issues and PRs is approximately 1092 hours, with a mean of 12965 hours, indicating variable response times across different types of requests. Enhancement requests are the most common issue type with 5 tracked instances, followed by help wanted requests with 3 instances and bug reports with 2 instances. The most active contributors tracked are sysadmind with 54 events, SuperQ with 28 events, and isaiasanchez with 7 events. The repository shares contributors with microsoft/vscode, keycloak/keycloak, and microsoft/typescript, indicating cross-project collaboration within the broader open-source ecosystem.
The exporter includes advanced features such as configurable collection timeouts to prevent connection exhaustion when databases respond slowly, support for custom queries through external YAML files, metric prefix customization, and flexible logging with both logfmt and JSON output formats. It can be deployed with systemd socket activation on Linux systems and supports TLS and basic authentication through web configuration files.