Exporter log error "queryNamespaceMappings returned 1 errors" when running custom query

Open
#965 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

The report points to namespace.go:236 and postgres_exporter.go:682; start by tracing how PG_EXPORTER_AUTO_DISCOVER_DATABASES applies configured custom queries across databases. Define and verify a way for pg_open to target one database, with the query running there without relation-not-found or error logs on other databases. No test file is named in the report.

Written by the indexing model from the issue text.

Description

What did you do?
I have 1 postgres server with multiple databases for multiple services, and I run multiple metrics on all databases,
And I want to setup a custom query for specific database.

the query:

    pg_open:
      query: "SELECT status status,count(*) total FROM repository group by status"
      metrics:
        - status:
            usage: "LABEL"
            description: "status"      
        - total:
            usage: "GAUGE"
            description: "total"  

What did you expect to see?
To not see error logs from running this query, I want this query to run on 1 database only.

What did you see instead? Under which circumstances?
Error logs:

caller=namespace.go:236 level=info err="Error running query on database \"localhost:5432\": pg_open pq: relation \"repository\" does not exist"
caller=postgres_exporter.go:682 level=error err="queryNamespaceMappings returned 1 errors"

Environment

  • System information:

Linux 5.15.0-79-generic x86_64

  • postgres_exporter version:

postgres_exporter, version 0.15.0 (branch: HEAD, revision: 68c176b8833b7580bf847cecf60f8e0ad5923f9a)
build user: root@05d0b99bd5f7
build date: 20231108-12:59:10
go version: go1.20.11
platform: linux/amd64
tags: unknown

  • postgres_exporter flags:
        - name: DATA_SOURCE_USER
          value: postgres
        - name: DATA_SOURCE_URI
          value: localhost?sslmode=disable
        - name: PG_EXPORTER_EXTEND_QUERY_PATH
          value: /config/queries.yaml
        - name: PG_EXPORTER_AUTO_DISCOVER_DATABASES
          value: 'true'
  • PostgreSQL version:

postgres:13-alpine

  • Exporter Logs:
caller=namespace.go:236 level=info err="Error running query on database \"localhost:5432\": pg_open pq: relation \"repository\" does not exist"
caller=postgres_exporter.go:682 level=error err="queryNamespaceMappings returned 1 errors"
Dominant language
Go
Stars
3.6k
Forks
835
Avg merge
2d 4h
Merged PRs (30d)
10

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.

More from prometheus-community/postgres_exporter

All issues in prometheus-community/postgres_exporter

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.