Provisioning of postgres datasources not working

Hi, I’ve added in the grafana/latest docker container an provisioning
of a postgres datasource, and put it under: /etc/grafana/provisioning/datasources

The datasource:

apiVersion: 1

datasources:
  - name: 'Postgres'
    type: 'postgres'
    url: 'db-test.customers.com:5432'
    user: 'grafana_readonly'
    secureJsonData:
      password: 'SeeSecretServer'
    jsonData:
      database: 'iagent'
      sslmode: 'disable'
      maxOpenConns: 35
      maxIdleConns: 35
      maxIdleConnsAuto: 'true'
      connMaxLifetime: '14400'
      postgresVersion: '14400'
      timescaledb: 'false'

I restartet the docker container, and the datasource is not editable.
When I try to create a dashboard with this datasource I’m getting
Data source with UID “P44368ADAD746BC27” not found.

What am I’m doing wrong.

How do we reproduce it?
Pull the latest grafana docker container
Put my datasource default.yaml file under /etc/grafana/provisioning/datasources
restart the container, and wait that the datasource can be used.

Grafana: grafana version 10.3.4
OS: Win 10
Browser: Firefox 128.0

Im getting this screen without postgres configuration details:

When I add a postgres Datasource with the gui everything is working.
But thats not the point, I need some automatisation to put this datasource up for 100 Systems.

Provision datasource uid explicitly, otherwise Grafana will use random uid and not that old one which you have saved/used in the dashboard.

1 Like

Hi, thanks for the post.
The following will work for me:

apiVersion: 1
datasources:
  - name: grafana-postgresql-datasource
    type: postgres
    access: proxy
    orgId: 1
    uid: grafana-postgresql-datasource
    url: db-test.customers.com:5432
    user: grafana_readonly
    secureJsonData:
      password: 'SeeSecretServer'
    jsonData:
      database: iagent
      sslmode: disable # disable/require/verify-ca/verify-full
      maxOpenConns: 100 # Grafana v5.4+
      maxIdleConns: 100 # Grafana v5.4+
      maxIdleConnsAuto: true # Grafana v9.5.1+
      connMaxLifetime: 14400 # Grafana v5.4+
      postgresVersion: 1400 # 903=9.3, 904=9.4, 905=9.5, 906=9.6, 1000=10
      timescaledb: false
    version: 2
    editable: true