liron5
February 15, 2022, 10:53am
1
I’m trying to initlizze Grafna using docker (setup the Grfana container using docker-compose.yml). On of my datasources is Postgresql.
I’m trying to set up with provisioning/datasources/postgres.yml:
deleteDatasources:
- name: 'PostgreSQL'
org_id: 1
datasources:
- name: 'PostgreSQL'
type: 'postgres'
url: myserver.database.azure.com:5432
user: foo@myserver
editable: true
org_id: 1
is_default: true
database: foo
secureJsonData:
password: 'password7890!'
jsonData:
sslmode: 'disable'
postgres_version: 1100
timescaledb: true
For some reason the password field isn’t filled.
Do you have idea why it happens and how can I fix it?
related: see this new GH issue:
opened 03:48PM - 23 Feb 22 UTC
<!--
Please use this template to create your bug report. By providing as much i… nfo as possible you help us understand the issue, reproduce it and resolve it for you quicker. Therefore take a couple of extra minutes to make sure you have provided all info needed.
PROTIP: record your screen and attach it as a gif to showcase the issue.
- Questions should be posted to: https://localhost:3000
- Use query inspector to troubleshoot issues: https://bit.ly/2XNF6YS
- How to record and attach gif: https://bit.ly/2Mi8T6K
-->
**What happened**:
I have defined a PSQL datasource like:
```yml
apiVersion: 1
deleteDatasources: []
datasources:
- access: proxy
name: DEMOPSQL
type: postgres
user: demouser
password: demopassword
database: demodb
basicAuth: false
orgId: 1
jsonData:
postgresVersion: 1200
sslmode: disable
timeInterval: 1s
timescaledb: true
tlsAuth: false
tlsAuthWithCACert: false
tlsConfigurationMethod: file-path
tlsSkipVerify: true
```
However I get a connection error, in grafana and in Postgresql:
```
2022-02-23 16:10:52.089 CET [3153285] demouser@demodb FATAL: password authentication failed for user "demouser"
2022-02-23 16:10:52.089 CET [3153285] demouser@demodb DETAIL: Password does not match for user "demouser".
Connection matched pg_hba.conf line 96: "host all all 127.0.0.1/32 md5"
```
I've tested the connection properties with psql, and everything worked.
Without recompiled grafana, I've attached a GDB to the production (no debugsym) release of grafana `8.4.1` and found (with some hardcore work) that function generateConnectionString ( see https://github.com/grafana/grafana/blob/main/pkg/tsdb/postgres/postgres.go#L118 ) is returning the following string:
`user='demouser' password='' host='' dbname='demodb' sslmode='disable'`
So, after investigating for a while, I'm confident there is something blocling the field "password" from being loaded on datasource provisioning.
This kind of datasources worked at grafana 8.0.x and I think in 8.1.x too but stop working at 8.2.x
**What you expected to happen**:
The password is correctly loaded and the datasource become usable widely
**How to reproduce it (as minimally and precisely as possible)**:
Just copy the provisioning yml and create the corresponding psql DB/user/passwd.
**Anything else we need to know?**:
**Environment**:
- Grafana version: 8.4.1
- Data source type & version: Postgresql / Provisioned datasource
- OS Grafana is installed on: Ubuntu 20
- User OS & Browser: Fedora & google chrome
- Grafana plugins: standard
- Others: Please, request if you need something more
Thank for your time and attention