prometheus-community / prometheus-community/postgres_exporter
Metric enrichment
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 3.6k
- Forks
- 835
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 10
Description
Hi.
I just started using the latest postgres_exporter in k8s. And it's cool! But I have one issue.
I am using single pod in k8s with the env DATA_SOURCE_NAME with two different hosts and DBs:
env:
- name: DATA_SOURCE_NAME
value: "host=host1 port=5432 dbname=db1 user=user1 sslmode=disable,host=host2 port=5432 dbname=db2 user=user2 sslmode=disable"
I want to monitor just availability of DB's using "pg_exporter_last_scrape_error" or "pg_up". But this metrics don't have the DB and hostname in it's data like "pg_locks_count":
# HELP pg_exporter_last_scrape_error Whether the last scrape of metrics from PostgreSQL resulted in an error (1 for error, 0 for success).
# TYPE pg_exporter_last_scrape_error gauge
pg_exporter_last_scrape_error 0
# HELP pg_up Whether the last scrape of metrics from PostgreSQL was able to connect to the server (1 for yes, 0 for no).
# TYPE pg_up gauge
pg_up 1
# HELP pg_locks_count Number of locks
# TYPE pg_locks_count gauge
pg_locks_count{datname="db1",mode="accessexclusivelock",server="host1:5432"} 0
For example, I want to alert if one of DB's can't be accessed (pg_exporter_last_scrape_error returns 1). But how can I add the "broken" DB and host name to the alert if metric doesn't have that info?
#452 is about the same issue
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how pg_up and pg_exporter_last_scrape_error are produced for multiple PostgreSQL targets, then compare their labels with pg_locks_count. Review issue #452 for related context. Done means availability metrics identify the corresponding database and host so alerts can name an unreachable target.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql, prometheus
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100