Environment variables in datasource provisioning file not working

Hi everyone,

I use Grafana in Docker (latest image from Docker Hub) and have an issue with using environment variables with provisioning file for datasources - datasources.yml.
According to github issue https://github.com/grafana/grafana/pull/16499 this should be supported.

Here is the output in the container.

bash-5.0$ more /etc/grafana/provisioning/datasources/datasources.yaml

# JTI raw databases
- name: juniper_1
  type: influxdb
  access: proxy
  orgId: 1
  url: http://db_1:8086
  password: $INFLUXDB_PASS
  database: juniper
  basicAuth: false
  isDefault: false
  editable: false

bash-5.0$ env | grep INFLUX 

Now here is the behavior I haven’t expected: With this configuration when I enter Grafana web UI and go to the dashboard page, it tries to load data from the database for each panel, and then it prompts me to enter username and password with the following description:

The server is asking for your username and password. The server reports that it is from InfluxDB.


Obviously with the same user and pass which are in container’s environment variables directly in the file it works without any issue.

Any clues on this, has this been tested by someone?

Many thanks,
Dusan Pajin


I have absolutely the same issue

My issue was that I was missing the first line:
apiVersion: 1


This is helped
Thank you
I just read the documentation saw the first example, also download the example from github and there was absolutely the same template without apiVersion: 1
Docs should have warn about it - “Variable will not work without apiVersion: 1”


I have a Grafana 7.5.5 Docker Image and i do have apiVersion: 1, still get this issue.

Variables are passed from docker-compose.

How to troubleshoot this ?

Thanks in advance,