postgres_exporter icon indicating copy to clipboard operation
postgres_exporter copied to clipboard

"target is required" when trying to fetch metrics

Open mapausch opened this issue 1 year ago • 2 comments

What did you do?

  • created a monitoring-user on my PostgreSQL db and granted roles pg_monitor, pg_read_all_stats
  • started container according to the docs:

user@grafan-host$ podman run --net=host -e DATA_SOURCE_NAME='postgresql://monitoring-user:monitoring-password@pgsql-host:5432/postgres?sslmode=disable' quay.io/prometheuscommunity/postgres-exporter ts=2024-06-24T14:11:32.258Z caller=main.go:86 level=warn msg="Error loading config" err="Error opening config file \"postgres_exporter.yml\": open postgres_exporter.yml: no such file or directory" ts=2024-06-24T14:11:32.258Z caller=proc.go:267 msg="Excluded databases" databases=[] ts=2024-06-24T14:11:32.259Z caller=tls_config.go:274 level=info msg="Listening on" address=[::]:9187 ts=2024-06-24T14:11:32.259Z caller=tls_config.go:277 level=info msg="TLS is disabled." http2=false address=[::]:9187

  • tried to fetch metrics with curl
user@grafan-host$ curl http://localhost:9187/probe
target is required

What did you expect to see? the metrics that postgresql_exporter fetches from database

What did you see instead? Under which circumstances?

  • "target is required" (see above output of curl)
  • postgres_exporter doesn't even try to connect to the database on postgresql-host

Environment

  • System information:
$ uname -srm
Linux 5.15.0-204.147.6.2.el9uek.x86_64 x86_64
  • postgres_exporter version:
user@grafan-host$ podman exec -it container-name /bin/sh
/ $ postgres_exporter --version
postgres_exporter, version 0.15.0 (branch: HEAD, revision: 68c176b8833b7580bf847cecf60f8e0ad5923f9a)
  build user:       root@88f74f2c2888
  build date:       20231027-14:38:56
  go version:       go1.21.3
  platform:         linux/amd64
  tags:             unknown

  • postgres_exporter flags:
N/A
  • PostgreSQL version:

    16

  • Logs:

insert logs relevant to the issue here

mapausch avatar Jun 24 '24 14:06 mapausch

according to the Readme "multi-target functionality of this exporter is optional", so I assume I don't need any "?target=..." at the end of the URL... ?

mapausch avatar Jun 24 '24 14:06 mapausch

luckily found this PR: https://github.com/prometheus-community/postgres_exporter/pull/1038

Started container with podman run --net=host -e DATA_SOURCE_URI='pgsql-host:5432/postgres?sslmode=disable' -e DATA_SOURCE_USER=monitoring-user -e DATA_SOURCE_PASS=monitoring-password quay.io/prometheuscommunity/postgres-exporter

and tried to fetch metrics with curl http://localhost:9187/metrics (instead of "/probe")

now it seems to work :-)

[...]
pg_database_size_bytes{datname="postgres"} 7.5117027e+07
pg_database_size_bytes{datname="template0"} 7.520783e+06
pg_database_size_bytes{datname="template1"} 7.754211e+06
[...]

mapausch avatar Jun 25 '24 06:06 mapausch