Error opening connection to database(could not parse DATA_SOURCE_NAME) - Using a password which contain special characters.
Getting below error in kubectl POD while connecting to prometheus-postgres-exporter, version 2.0.0 Config params: POSTGRES_EXPORTER_IMAGE_REPOSITORY=wrouesnel/postgres_exporter POSTGRES_EXPORTER_IMAGE_TAG=v0.8.0 POSTGRES_EXPORTER_IMAGE_PULL_POLICY=IfNotPresent
POSTGRES_EXPORTER_CHART=msa-upstream/prometheus-postgres-exporter POSTGRES_EXPORTER_VERSION=2.0.0
POSTGRES_EXPORTER_DATASOURCE_HOST=<host_name>
POSTGRES_EXPORTER_DATASOURCE_USER=
Error:
time="2022-07-20T11:54:50Z" level=error msg="Error opening connection to database (could not parse DATA_SOURCE_NAME): parse postgresql://pgadmin:
Note: Password has special characters, also tried providing password in double quotes: "
Please let me know if you need more information.
I met the same problem. And I try to fix it by replacing the sepecial characters with its %+ascii format. Because special characters in url (eg: postgresql://user:passwd@localhost:5432/postgres?sslmode=disable) mean specially and can not directly be parsed, eg: ! -> %21 , # -> %23
Currently DSNs that are of the form "postgresql://" are parsed by the URL library. This means that special characters must be valid URLs.
I met the same problem. And I try to fix it by replacing the sepecial characters with its %+ascii format. Because special characters in url (eg: postgresql://user:passwd@localhost:5432/postgres?sslmode=disable) mean specially and can not directly be parsed, eg: ! -> %21 , # -> %23
Solved the problem! Thanks. Here is percent encoding characters table.