Skip to content
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

Multi-target support issue with UNIX socket path encoding #1058

Open
caseyandgina opened this issue Aug 9, 2024 · 1 comment
Open

Multi-target support issue with UNIX socket path encoding #1058

caseyandgina opened this issue Aug 9, 2024 · 1 comment

Comments

@caseyandgina
Copy link

caseyandgina commented Aug 9, 2024

I'd like to collect metrics like analyze/vacuum stats for tables in multiple databases, not just the one in the primary DSN. I'm trying to use multi-target support for this, but running into an issue when using a UNIX socket for the connection, as the slashes in the path aren't being decoded correctly.

For example, the following URL:

http://localhost:9187/probe?target=user=app_prometheus_postgres_exporter%20dbname=postgres%20host=%2Frun%2Fpostgresql%20port=5432

Results in:

caller=probe.go:81 level=error target="user=app_prometheus_postgres_exporter dbname=postgres host=/run/postgresql port=5432" msg="Error opening connection to database" err="error querying postgresql version: parse \"postgresql://app_prometheus_postgres_exporter:@%2Frun%2Fpostgresql:5432?dbname=postgres\": invalid URL escape \"%2F\""
caller=postgres_exporter.go:682 level=error err="Error opening connection to database (could not parse DATA_SOURCE_NAME): parse \"postgresql://app_prometheus_postgres_exporter:@%2Frun%2Fpostgresql:5432?dbname=postgres\": invalid URL escape \"%2F\""

If there's a better/simpler way, please let me know.

@caseyandgina
Copy link
Author

caseyandgina commented Aug 9, 2024

With this URL:
http://localhost:9187/probe?target=app_prometheus_postgres_exporter@%2Frun%2Fpostgresql:5432/postgres

It interprets the first %2F as a separator and everything after it as a db name, trying to use a TCP connection instead:

caller=probe.go:81 level=error target=app_prometheus_postgres_exporter@/run/postgresql:5432/postgres msg="Error opening connection to database" err="error querying postgresql version: pq: no pg_hba.conf entry for host \"127.0.0.1\", user \"app_prometheus_postgres_exporter\", database \"run/postgresql:5432/postgres\", SSL encryption"
caller=postgres_exporter.go:682 level=error err="Error opening connection to database (postgresql://app_prometheus_postgres_exporter:PASSWORD_REMOVED@/run/postgresql:5432/postgres): pq: no pg_hba.conf entry for host \"127.0.0.1\", user \"app_prometheus_postgres_exporter\", database \"run/postgresql:5432/postgres\", SSL encryption

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