https://github.com/coroot/coroot-pg-agent
A Prometheus exporter for Postgres focusing on query performance statistics
https://github.com/coroot/coroot-pg-agent
monitoring postgresql postgresql-metrics postgresql-monitoring prometheus prometheus-exporter
Last synced: about 2 months ago
JSON representation
A Prometheus exporter for Postgres focusing on query performance statistics
- Host: GitHub
- URL: https://github.com/coroot/coroot-pg-agent
- Owner: coroot
- License: apache-2.0
- Created: 2021-09-20T14:27:58.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-24T13:41:27.000Z (about 2 months ago)
- Last Synced: 2025-03-28T22:12:18.223Z (about 2 months ago)
- Topics: monitoring, postgresql, postgresql-metrics, postgresql-monitoring, prometheus, prometheus-exporter
- Language: Go
- Homepage: https://docs.coroot.com/metrics/cluster-agent#postgres
- Size: 59.6 KB
- Stars: 142
- Watchers: 5
- Forks: 18
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Coroot-pg-agent
[](https://goreportcard.com/report/github.com/coroot/coroot-pg-agent)
[](https://opensource.org/licenses/Apache-2.0)Coroot-pg-agent is an open-source prometheus exporter that gathers metrics from Postgres servers.
## Philosophy
Metrics should help you identify issues with your Postgres servers.
This agent collects metrics that can help you answer questions such as:
* What queries are consuming the most IOPS or CPU time?
* Which transactions are hanging in the *Idle in transaction* state?
* Which query is holding the lock?This provides visibility into Postgres performance without the need to navigate through system views manually.
## Features### Comprehensive query metrics
The agent aggregates data from *pg_stat_statements* and *pg_stat_activity* to provide accurate
metrics about queries, whether they are completed or still running.
![]()
Learn more about query metrics in the blog post "[Missing metrics required to gain visibility into Postgres performance](https://coroot.com/blog/pg-missing-metrics)"
### Locks monitoring
It is not enough to gather the number of active locks from *pg_locks*.
What engineers really want to know is which query is blocking other queries.
The [pg_lock_awaiting_queries](https://docs.coroot.com/metrics/cluster-agent#pg_lock_awaiting_queries) metric can provide the answer to that.### Query normalization and obfuscation
In addition to query normalization, which Postgres does, the agent obfuscates all queries so that no sensitive data gets into the metrics labels.
## Quick start
### Create database role
create role with login password '';
grant pg_monitor to ;### Enable pg_stat_statements
create extension pg_stat_statements;
select * from pg_stat_statements; -- to check### Run
docker run --detach --name coroot-pg-agent \
--env DSN="postgresql://:@:5432/postgres?connect_timeout=1&statement_timeout=30000" \
ghcr.io/coroot/coroot-pg-agent## Metrics
The collected metrics are described [here](https://docs.coroot.com/metrics/cluster-agent#postgres).
## License
Coroot-pg-agent is licensed under the [Apache License, Version 2.0](https://github.com/coroot/coroot-node-agent/blob/main/LICENSE).