No description
Find a file
Kumi 158c725ab4
feat: Add Postgres Connection Exporter service
Introduced a new systemd service for the Postgres Connection Exporter, enhancing monitoring capabilities by tracking database connections. This service configuration ensures it starts after the network is available, runs under a dedicated user and group for security, and is set to automatically restart upon failure, ensuring high availability. The setup aims to streamline deployment and maintenance processes for systems requiring constant database connection monitoring.

The service is designed to be easily integrated into multi-user environments, adhering to best practices for system services.
2024-05-17 15:54:25 +02:00
contrib feat: Add Postgres Connection Exporter service 2024-05-17 15:54:25 +02:00
src/postgres_connection_exporter feat: Enhance config flexibility and setup 2024-05-16 06:33:21 +02:00
.gitignore feat: Enhance config flexibility and setup 2024-05-16 06:33:21 +02:00
CHANGELOG.md feat: Enhance config flexibility and setup 2024-05-16 06:33:21 +02:00
LICENSE feat: Initial implementation of a PostgreSQL connection exporter 2024-05-15 22:41:26 +02:00
pyproject.toml feat: Enhance config flexibility and setup 2024-05-16 06:33:21 +02:00
README.md feat: Enhance config flexibility and setup 2024-05-16 06:33:21 +02:00

PostgreSQL Connection Exporter for Prometheus

This is a simple server that exports PostgreSQL connection metrics in a format that can be scraped by Prometheus.

It outputs the following metrics:

  • The number of connections per database
  • The number of connections per user
  • The number of connections per client address
  • The number of connections per state

Installation

You can install the exporter from PyPI. Within a virtual environment, run:

pip install postgres-connection-exporter

Configuration

The exporter is configured using a config.yaml. You can create a default configuration file in the current working directory with:

postgres-connection-exporter --create-config

Now, edit the config.yaml file to match your PostgreSQL connection settings. Here is an example configuration:

hosts:
  host: localhost
  port: 5432
  user: postgres
  password: postgres

The user must have the pg_monitor role to access the pg_stat_activity view.

Usage

After you have created your config.yaml, you can start the exporter with:

postgres-connection-exporter

By default, the exporter listens on localhost:8989. You can change the address in the config.yaml file, or using the --host and --port flags:

postgres-connection-exporter --host 0.0.0.0 --port 9898

You can also specify a different configuration file with the --config flag:

postgres-connection-exporter --config /path/to/config.yaml

License

This project is licensed under the MIT License. See the LICENSE file for details.