-
Notifications
You must be signed in to change notification settings - Fork 109
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
Can't use UNIX socket connection #133
Comments
@caseyandgina your database hostname/IP is misconfigured: /run/postgresql should be replaced with the hostname or IP of the database. |
No, that would open a TCP connection, rather than UNIX socket. There's no point in using a TCP for a local connection. Note the following URI works with psql (as with generally anything else that accepts a URI database connection string) and there isn't a client_id/client_addr for a UNIX socket connection:
|
UNIX socket connections have less overhead, and they can be more secure since access can be further regulated through permissions on the socket file ( |
This is expected and not something that's currently supported. The current implementation is only using URLs and uses url.Parse for most of the supported databases ( Line 246 in 0001728
It could probably be implemented, so if you are interested in that you could open a PR. |
FYI:
sql_exporter/vendor/github.com/lib/pq/doc.go Lines 42 to 49 in 3f78c6b
For PostgreSQL, this is already supported by using the host keyword as such:
|
Nice, so I think we can close this issue right? |
'user=app_sql_exporter dbname=postgres host=/run/postgresql port=5432'
...results in:
{"caller":"job.go:189","err":"sql: unknown driver \"\" (forgotten import?)","job":"example","level":"warn","msg":"Failed to connect","ts":"2024-07-26T17:50:10.540688846Z"}
'postgres://app_sql_exporter:testpw@%2Frun%2Fpostgresql:5432/postgres'
...results in:
{"caller":"job.go:104","err":"parse \"postgres://app_sql_exporter@%2Frun%2Fpostgresql:5432/postgres\": invalid URL escape \"%2F\"","job":"example","level":"error","msg":"Failed to parse URL","ts":"2024-07-26T17:49:26.091765976Z","url":"postgres://app_sql_exporter@%2Frun%2Fpostgresql:5432/postgres"}
'postgres://app_sql_exporter:testpw@/run/postgresql:5432/postgres'
...results in:
{"caller":"job.go:189","err":"pq: no pg_hba.conf entry for host \"127.0.0.1\", user \"app_sql_exporter\", database \"run/postgresql:5432/postgres\", SSL encryption","job":"example","level":"warn","msg":"Failed to connect","ts":"2024-07-26T17:48:58.382065441Z"}
The text was updated successfully, but these errors were encountered: