Provisioning a datasource with token in environment variable

Following the documentation on the provision feature found here.

I have a datasource config file at /etc/grafana/provisioning/datasources/influxdb.yaml.

The contents of which is the following.

apiVersion: 1

- name: InfluxDB
  type: influxdb
  uid: influxdb
  url: http://localhost:8086
  editable: true
  isDefault: true
  version: 1
    defaultBucket: speed_tests
    httpMode: POST
    organization: internet_monitor
    version: Flux
    readOnly: true
    token: $INFLUXDB_TOKEN

When I start grafana-server via systemctl or delete this datasource and restart grafana-server.

The InfluxDB datasource is created but the token is empty and unset.

How can I provide the INFLUXDB_TOKEN environment variable to the systemd managed daemon?

I’ve tried setting the value of this variable in /etc/sysconfig/grafana-server but this hasn’t worked either.

$ cat /etc/sysconfig/grafana-server

Figured it out.

If the grafana-server is being started via systemd you’ll find there’s a parameter called EnvironmentFile=.

Which in /lib/systemd/system/grafana-server.service you’ll find is set as follows by default.


This means you can add variables to /etc/default/grafana-server e.g.


Then this variable will be available to the config files in /etc/grafana/provisioing.