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.
Metadata
Release files for postgres-connection-exporter 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| postgres_connection_exporter-0.0.2.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| postgres_connection_exporter-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.4 kB
Release files / postgres_connection_exporter-0.0.2.tar.gz
| Download URL | postgres_connection_exporter-0.0.2.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9ea4050eeff6622929b779330b8771388ad262adc1f163cb837f4ecfefcb55c
|
|
BLAKE2b-256 checksum How to use checksums |
bcf1abdbcd44d3e56cbec531ae9d8dd1932342096145107e1e6ade5e5bf66bea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / postgres_connection_exporter-0.0.2-py3-none-any.whl
| Download URL | postgres_connection_exporter-0.0.2-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f0d896230c747f4bbbacc3748e731d4b9ed148ade2651fe034427ce9ba87c01
|
|
BLAKE2b-256 checksum How to use checksums |
a7dee60263d9c59ea8a52d2d6a64de5721889bd908314b3612c536cff915340a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|