pgsty / pgsty/pg_exporter

pg_locks

Open Beginner friendly
#107 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
363
Forks
59
PR merge metrics
No merged PRs in 30d

Description

Hi,
i would prefer to reduce the amount of data and skip lock modes that are absent but add granted and locktype to pg_locks:

pg_lock:
  name: pg_lock
  desc: PostgreSQL lock distribution by mode and database incl. granted
  query: |-
    SELECT d.datname, locktype, mode, granted, count(*) AS count
        FROM pg_locks JOIN pg_database d on d.oid=database
        WHERE DATABASE IS NOT NULL
        GROUP BY 1, 2, 3, 4 ;

  min_version: 090400
  tags: [ cluster ]
  metrics:
    - datname: { usage: LABEL ,description: "Name of the database this backend is connected to" }
    - locktype: { usage: LABEL ,description: "Locktype" }
    - mode:    { usage: LABEL ,description: "Name of the lock mode held or desired by this process" }
    - granted: { usage: LABEL ,description: "granted" }
    - count:   { usage: GAUGE ,description: "Number of locks of corresponding mode and database" }

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 existing pg_lock metric definition and review how its current pg_locks query is configured. Update it to group by locktype, mode, and granted while omitting absent lock modes and excess data; done means the exported metric has the requested labels and count for each database.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql
Domain
databases, observability
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.