prometheus-community / prometheus-community/postgres_exporter

Add "granted" to pg_locks_count as a label

Open
#657 0 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
3.6k
Forks
835
Avg merge
2d 4h
Merged PRs (30d)
10

Description

Proposal

The current pg_locks_count metric doesn't differentiate between granted and not granted locks. To learn about the current congestion in the database, it would be good to divide the number of locks between granted and not-yet-granted locks.

Link to the table definition in the PostgreSQL docs: https://www.postgresql.org/docs/current/view-pg-locks.html

For now, I'll go with a custom query, still I'd assume this feature would be helpful for other as well.

Starting with PostgreSQL 14 there is also the column waitstart that would allow to calculate the accumulated waiting time for all not-yet-granted locks. I assume that would be a different metric.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the exporter query or entry point that produces the pg_locks_count metric, then compare it with PostgreSQL's pg_locks table definition. Add a granted distinction so granted and not-yet-granted locks can be counted separately, and verify the resulting metric preserves the existing count while exposing both states.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql, prometheus
Domain
databases, observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.