How to Build Grafana Dashboards with InfluxDB, Flux and InfluxQL

We’re excited about the release of Grafana 7.1, which extends Grafana’s built-in InfluxDB datasource to run queries in both the Flux language and InfluxQL. This means it’s super easy to connect Grafana to InfluxDB — whether you use InfluxDB 1.8 or 2.0, Flux or InfluxQL.

Because this InfluxDB datasource is built into Grafana 7.1, there is no separate plugin to download and install. You get a simplified configuration experience that’s the result of the Grafana and InfluxData engineering teams working closely over the past several months, and one more step in our journey to “time to awesome”.

If you’re an InfluxDB Cloud 2 user, Grafana has updated the InfluxDB Data Source to support Flux, without requiring you to separately install a Flux plugin.

If you’re an InfluxDB 1.x user, now you can use Flux queries in your Grafana dashboards, in addition to InfluxQL. Use Grafana 7.1 to create a new InfluxDB Data Source and choose Flux as the language. Flux allows you to write queries that go beyond the limits of InfluxQL, as explained below. Of course, your existing InfluxQL queries will continue to work as they always have.

Leverage InfluxQL in InfluxDB Cloud 2 with Grafana 7.1

Do more in your Grafana dashboard queries

  • Joins, to create graphs that span multiple buckets. For example, you might want a Grafana chart that displays both bytes transferred and requests per second; Flux allows you to query these two measurements and join them into a single table.
  • Math across measurements, which go beyond simple joins to allow you to do math on columns in the joined table. For example, you might want to divide an error rate by a request rate to get an error rate percentage.
  • Multiple datasources, allowing you to enrich time series data with metadata from relational databases such as MySQL, MariaDB, Postgres, Microsoft SQL Server, Snowflake, SQLite, AWS Athena, and Google BigTable; or from CSV files. This is useful when, for example, your time series data includes customer number fields but not customer names. Flux allows you to pull in the customer name so that it can be displayed in your Grafana dashboards. Here are some tutorials that explain further.

Other features unique to Flux include:

Here’s a detailed comparison of InfluxQL and Flux with code samples.

How to integrate Grafana with InfluxDB

Click on Add data source:

Hover over InfluxDB, then click Select:

So far, this probably looks familiar if you’ve used Grafana previously. But here’s what’s new in Grafana 7.1: the ability to choose which language you want to use, InfluxQL or Flux:

If you choose InfluxQL, you’ll see the configuration page below. When filling in the URL field, keep in mind that for InfluxDB 1.8, the default port is 8086. For InfluxDB Cloud 2, here are the URLs that you can use. Further details are in this documentation page.

And if you choose Flux, here’s what to specify:

  1. Choose the InfluxDB data source
  2. Choose the Flux language
  3. Fill in the connection details with your InfluxDB Cloud 2 URL, organization, token, and bucket

… as shown in the screenshot below. Here I’ve specified AWS US West 2 (Oregon) in my URL, but you might be running in a different region. Your org name and bucket name will probably be different as well.

You can also create multiple InfluxDB Data Sources in Grafana. You have a lot of flexibility here. You can, for instance:

  • Create two data sources that point to the same InfluxDB instance, once of which uses Flux, and another that uses InfluxQL. (See screenshot below.)
  • Create multiple data sources to connect to different InfluxDB instances.

Demo of Grafana, InfluxDB, Flux and InfluxQL

https://www.youtube.com/watch?v=ohtUVe_B7o8&feature=emb_logo

More flexibility around writes

Availability

Let’s dive into the details of the integration. Between all the different variants of Grafana, InfluxDB, and language (InfluxQL/Flux), there are a lot of possible combinations.

The new InfluxDB datasource for Grafana work for Grafana 7.1 whether you’re using Grafana open source, Grafana Enterprise, or Grafana Cloud, and supports:

  • Grafana 7.1 dashboards using Flux, running against InfluxDB Cloud 2, InfluxDB OSS 2.0, or InfluxDB 1.8+ (Enterprise, Cloud 1, or OSS)
  • Grafana 7.1 dashboards using InfluxQL, running against InfluxDB Cloud 2, or InfluxDB 1.8+ (Enterprise, Cloud 1, or OSS)

Or if you prefer a table view:

InfluxDB Product Version InfluxQL? Flux? Open Source 1.8 Yes Yes Enterprise 1.8 Yes Yes Cloud 1.8 Yes Yes Cloud 2.0 Yes Yes Open Source 2.0 No, coming later this year Yes

I want to be upfront about one integration that does not currently exist — but which we plan to deliver later this year:

Grafana 7.1 dashboards using InfluxQL, running against InfluxDB OSS 2.0.

What’s the price of Grafana + InfluxDB integration?

Get started with Grafana and InfluxDB

Once you’ve gotten Grafana and InfluxDB up and running, see this guide on how to integrate InfluxDB 1.8 with Grafana, and this document on integrating InfluxDB 2.0 with Grafana. Then join our ever-helpful InfluxDB community and Slack for questions.

Enjoy!

Occasional thoughts on tech, sailing, and San Francisco