Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mapausch opened this issue Jun 24, 2024 · 2 comments
Closed

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

mapausch opened this issue Jun 24, 2024 · 2 comments

Comments

@mapausch
Copy link

mapausch commented Jun 24, 2024

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
Copy link
Author

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
Copy link
Author

luckily found this PR: #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 mapausch changed the title target is required "target is required" when trying to fetch metrics Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant