Flux VS Code Extension

Flux VS Code Extension

Source: Nidhinkumar

If you don’t have time to read but want to know what’s there in this post. Find the quick read 👇

Quick Read


In, this blog we will see how to install the Flux Extension in VS Code and make connections to InfluxDB and write queries.


If you are new to InfluxDB check out the below blogs before reading this one 👇

InfluxDB (TICK Stack) — Part1

  • InfluxDB with some data

  • VS Code Text Editor


  1. Installing Flux Extension

  2. Connecting InfluxDB with VS Code

  3. Writing Flux Query in VS Code

1. Installing Flux Extension

Open VS Code Editor and then click Extensions and then type Flux like below

Flux Extension

Click Install to install the Flux extension

Flux Extension

Once the extension is installed successfully you could see the InfluxDB on the sidebar like the below image


Click the ‘+’ button to add a new connection.

2. Connecting InfluxDB with VS Code

Now, we will connect the InfluxDB in VS Code. Click the ‘+’ button or by using the command palette (Ctrl + Shift + p) and then click the Add new connection.

Add new connection

Now select the connection and then add the InfluxDB token and then click the Test connection to check the connection.

Test Connection

Once the connection is successful you could see the buckets and measurements that are available in the given organization like below

Influx Buckets

3. Writing Flux Query in VS Code

Now, will write the Flux query to check whether we can get the data from InfluxDB.

Create a new file in VS Code Editor with extension as .flux and write your flux query.

from(bucket: "systemmetric")
|> range(start: -1h, stop: now())
|> filter(fn: (r) => r["_measurement"] == "cpu")
|> filter(fn: (r) => r["cpu"] == "cpu-total")
|> filter(fn: (r) => r["_field"] == "usage_user")
|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
|> yield(name: "mean")

Now run the flux query using the command Ctrl + Alt + E. Now you could see the result like below.

Flux Output


You have learned how to use the Flux Extension in VS Code. Will Catch you up in a new post till then Happy Learning:)