Using Flux from Grafana

After Getting started with Flux, you might be asking how to finally use it from Grafana?

Grafana datasource plugin for Flux (InfluxDB)


Use this datasource if you want to use Flux to query your InfluxDB. Feel free to run this datasource side-by-side with the non-Flux datasource. If you point both datasources to the same InfluxDB instance, you can switch query mode by switching the datasources.

State of the onion

While we already assumed to require the »Grafana datasource plugin for Flux (InfluxDB)«, there are currently two versions around:

We should use the most recent one. However, there is another commit Updated db: to bucket: to support new changes in Flux · grafana/influxdb-flux-datasource@ac49cf7 · GitHub sitting in the branch “bucket-updates” which most notably includes the switchover regarding addressing databases from within a Flux expression. Flux switched from

  • from(db: "${database}")


  • from(bucket: "${database}")

So, databases will be called buckets now. That’s ok.



curl -sS | sudo apt-key add -
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
apt update
apt install yarn


git clone /opt/grafana-influxdb-flux-datasource

cd /opt/grafana-influxdb-flux-datasource
yarn install
yarn dev


Note: Please make sure you uninstalled the GA release from the Grafana Plugin Repository by using e.g.

grafana-cli plugins uninstall grafana-influxdb-flux-datasource

Then, link the DEV release into the Grafana plugin directory:

ln -s /opt/grafana-influxdb-flux-datasource /var/lib/grafana/plugins/
systemctl restart grafana-server



Panel metrics


Please note there’s no need to configure a default database (so we used "null" there), as the database (bucket) is addressed from within the Flux query expression anyway. Thus, there will be probably no need to configure a different Grafana data source for each InfluxDB database - every query can be run through the canonical one, right?

Important note about Flux (again)

Flux requires a time range when querying time series data. “Unbounded” queries are very resource-intensive and as a protective measure, Flux will not query the database without a specified range.

Query InfluxDB with Flux | InfluxData Documentation

When sending an “unbounded” query to InfluxDB through Flux, like from(bucket:"hiveeyes_open_hive_clemens") without the range($range) part, it will respond appropriately:

Failed to create physical plan: result 'from0' is unbounded. 
Add a 'range' call to bound the query,

Data sources

Data sources for submitting Flux query expressions through Grafana have been added to both InfluxDB instances:


Example dashboard

[amo] Open Hive Clemens with Flux is an example dashboard which already uses Flux to query beekeeping data.

1 Like

This could be of interest for everyone playing with Flux in Grafana.

Wrong variable expansion format #13

Only _value column gets formatted #14

After asking upstream, promptly there’s a new release of the Grafana Flux plugin:

Thanks a bunch, David!

Update: Not quite there yet, see Getting Network Error: Not Found(404) · Issue #22 · grafana/influxdb-flux-datasource · GitHub.

Update: After some minor adjustments, installing the version 5.2.9 release bundle works like a charm.

Thanks again, David!

1 Like

Hi there,

as I’m sitting on the notification feed for this repository, I would like to share this piece with you:

Do some of the Flux experts from us have any opinion about that? @wtf, maybe?


As I’ve already been attending there [1,2,3] to gently push things forward while helping some others who have been running into similar issues we had when setting this up on our systems, there’s a slight chance this could also be interesting for us.

However, as I’m personally not into writing Flux queries yet but heard from @wtf that this is a detail he is currently into, I would need your statement about that. Just let me know if you would like to play with the amendments by Vadim, will be happy to install a fresh build from master as I did the other day.



[2] adding datasource getting Network Error: Not Found(404) · Issue #21 · grafana/influxdb-flux-datasource · GitHub
[3] Getting Network Error: Not Found(404) · Issue #22 · grafana/influxdb-flux-datasource · GitHub