Flux VS Code Extension

Source: NidhinkumarIf you don’t have time to read but want to know what’s there in this post. Find the quick read 👇Quick ReadOverviewIn, this blog we will see how to install the Flux Extension in VS Code and make connections to InfluxDB and write queri…


This content originally appeared on Level Up Coding - Medium and was authored by Nidhin kumar

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

Overview

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

Prerequisite

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

Objectives

  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

InfluxDB

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

Video Link

Congratulations!

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


Flux VS Code Extension was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Nidhin kumar


Print Share Comment Cite Upload Translate Updates
APA

Nidhin kumar | Sciencx (2022-02-21T02:19:17+00:00) Flux VS Code Extension. Retrieved from https://www.scien.cx/2022/02/21/flux-vs-code-extension/

MLA
" » Flux VS Code Extension." Nidhin kumar | Sciencx - Monday February 21, 2022, https://www.scien.cx/2022/02/21/flux-vs-code-extension/
HARVARD
Nidhin kumar | Sciencx Monday February 21, 2022 » Flux VS Code Extension., viewed ,<https://www.scien.cx/2022/02/21/flux-vs-code-extension/>
VANCOUVER
Nidhin kumar | Sciencx - » Flux VS Code Extension. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/21/flux-vs-code-extension/
CHICAGO
" » Flux VS Code Extension." Nidhin kumar | Sciencx - Accessed . https://www.scien.cx/2022/02/21/flux-vs-code-extension/
IEEE
" » Flux VS Code Extension." Nidhin kumar | Sciencx [Online]. Available: https://www.scien.cx/2022/02/21/flux-vs-code-extension/. [Accessed: ]
rf:citation
» Flux VS Code Extension | Nidhin kumar | Sciencx | https://www.scien.cx/2022/02/21/flux-vs-code-extension/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.