prometheus-community / prometheus-community/postgres_exporter

Facing error "metric pg_database_size_bytes was collected before with the same name and label values"

Open
#706 13 comments 0 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

What did you do?
We deployed postgres exporter version 0.11.1 on Azure using the official community helm chart. We are facing an issue with the below query from the chart:

pg_database: query: "SELECT pg_database.datname, pg_database_size(pg_database.datname) as size_bytes FROM pg_database" master: true cache_seconds: 30 metrics: - datname: usage: "LABEL" description: "Name of the database" - size_bytes: usage: "GAUGE" description: "Disk space used by the database"

We keep observing below error on the /metrics endpoint for the above query:

An error has occurred while serving metrics:

7 error(s) occurred:
* collected metric "pg_database_size_bytes" { label:<name:"datname" value:"azure_maintenance" > label:<name:"server" value:"<IP ADDRESS>:5432" > gauge:<value:8.401455e+06 > } was collected before with the same name and label values
* collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template1" > label:<name:"server" value:"<IP ADDRESS>:5432" > gauge:<value:8.159747e+06 > } was collected before with the same name and label values
* collected metric "pg_database_size_bytes" { label:<name:"datname" value:"postgres" > label:<name:"server" value:"<IP ADDRESS>:5432" > gauge:<value:8.589871e+06 > } was collected before with the same name and label values
* collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template0" > label:<name:"server" value:"<IP ADDRESS>:5432" > gauge:<value:8.159747e+06 > } was collected before with the same name and label values
* collected metric "pg_database_size_bytes" { label:<name:"datname" value:"azure_sys" > label:<name:"server" value:"<IP ADDRESS>:5432" > gauge:<value:8.974895e+06 > } was collected before with the same name and label values
* collected metric "pg_database_size_bytes" { label:<name:"datname" value:"testdb1" > label:<name:"server" value:"<IP ADDRESS>:5432" > gauge:<value:8.311343e+06 > } was collected before with the same name and label values
* collected metric "pg_database_size_bytes" { label:<name:"datname" value:"example" > label:<name:"server" value:"<IP ADDRESS>:5432" > gauge:<value:3.0814767e+07 > } was collected before with the same name and label values

What did you expect to see?
We expect to see regular metrices for pg_database_size_bytes with database name and size in labels

What did you see instead? Under which circumstances?
We keep seeing the error listed above on the /metrics endpoint

Environment
Azure

  • postgres_exporter version: 0.11.1

  • postgres_exporter flags: None

  • PostgreSQL version: 13.7

  • Logs: Found nothing specific in the logs.

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

Start at the /metrics endpoint and trace handling of the pg_database query configured in the community Helm chart. Reproduce with postgres_exporter 0.11.1, PostgreSQL 13.7, and the shown query, then inspect why identical pg_database_size_bytes samples are collected. Done means the endpoint exposes one valid metric series per database without duplicate-collection errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, helm, postgresql
Domain
databases, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.