prometheus-community / postgres_exporter

A PostgreSQL metric exporter for Prometheus
Apache License 2.0
2.83k stars 745 forks source link

"target is required" when trying to fetch metrics #1050

Closed mapausch closed 4 months ago

mapausch commented 5 months ago

What did you do?

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

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

What did you see instead? Under which circumstances?

Environment

$ uname -srm
Linux 5.15.0-204.147.6.2.el9uek.x86_64 x86_64
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
N/A
mapausch commented 5 months ago

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 commented 5 months ago

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
[...]