Provisioning Datasources - Selecting Flux Query Language

The documentation for writing datasources in the provisioning section is not quite up to date and I need help.

The provisioning example given at the end under the heading Configure the data source with provisioning - - is only for influxql query language.

I find no reference how to select the query language for flux or influxql and have searched everywhere.

The code below puts all the right data in the right places, but the datasource fails due to the influxql selected in the query language.

I made the datasource editable so that when the docker is created and I edit the datasource in the website and only change query language to flux, then everything works. So I know this is the last setting I need to fix to have everything working


default.yml file

apiVersion: 1

  - name: InfluxDB
    type: influxdb
    access: proxy
    password: ""
    user: ""
    database: ""
    basicAuth: false
    isDefault: true
    editable: true
      defaultBucket: "my-bucket"
      organization: "my-orgnaization"
      token: "my-token"

Two days of sweat and finally solved ! This solution is not only for flux in Influxdb but also for any datasource that you struggle to configure manually in a datasources file but can easily do it through the web interface.

1. Solution for using flux (not influxql) by provisioning a datasources file (good for docker)

apiVersion: 1
- orgId: 1
  version: 2
  name: InfluxDB
  type: influxdb
  access: proxy
  basicAuth: true
  isDefault: true
    defaultBucket: <my-bucket>
    httpMode: POST
    organization: <my-organization>
    version: Flux
    token: <my-token>

2. To find/create the yaml file for any datasources created in the grafana web interface.

You need admin/sudo access to both the website and the OS.

I used this very useful script with instructions here : to extract the datasources from a runnning grafana installation.

These are the instructions for a fresh blank docker linux os (ubuntu 20.04)

# Run a docker container if you don't want to install on a VM or your host machine
docker run -it -p 3000:3000 ubuntu bash

# The default ubuntu docker image when run bash will put you into root
# If you use a normal user or installation, then note that many commands here will need sudo access.

# Install Go and the Hamara program which will extract the datasources from grafana
apt-get -y update
apt-get install -y wget git
wget -c -O - | tar -xz -C /usr/local
export PATH=$PATH:/usr/local/go/bin
source ~/.profile
go version
go get -u

# Install and start Grafana
apt-get install -y apt-transport-https
apt-get install -y software-properties-common wget
wget -q -O - | apt-key add -
echo "deb stable main" | tee -a /etc/apt/sources.list.d/grafana.list
apt-get update
apt-get install -y grafana-enterprise 
service grafana-server start
service grafana-server status

# Now go to web interface at http://localhost:3000
# and setup all your datasources and test them
# And create an API token with admin privileges

# Now export all the datasources into a local file
export GRAFANA_API_KEY=<your token>
hamara export --host=localhost:3000 --key=$GRAFANA_API_KEY > datasources.yaml
./go/bin/hamara export --host=localhost:3000 --key=$GRAFANA_API_KEY > datasources.yaml

# Now read and copy all datasources
cat datasources.yaml