Use the Flux VS Code extension

The Flux Visual Studio Code (VS Code) extension provides Flux syntax highlighting, autocompletion, and a direct InfluxDB server integration that lets you run Flux scripts natively and show results in VS Code.

On this page

Install the Flux VS Code extension

The Flux VS Code extension is available in the Visual Studio Marketplace. For information about installing extensions from the Visual Studio marketplace, see the Extension Marketplace documentation.

Once installed, open the Explorer area of your VS Code user interface. A new InfluxDB pane is available below your file explorer.

InfluxDB pane in VS Code

Connect to InfluxDB

To create an InfluxDB connection in VS Code:

  1. Hover over the InfluxDB pane and then click the icon that appears.

    Add an InfluxDB connection in VS Code
  2. Provide the required connection credentials:

    • Type: type of InfluxDB data source. Select InfluxDB v2.
    • Name: unique identifier for your InfluxDB connection.
    • Hostname and Port: InfluxDB host and port (see InfluxDB OSS URLs or InfluxDB Cloud regions).
    • Token: InfluxDB API token.
    • Organization: InfluxDB organization name.
  3. Click Test to test the connection.

  4. Once tested successfully, click Save.

Manage InfluxDB connections

In the InfluxDB pane:

  • To edit a connection, right click on the connection to edit and select Edit Connection.
  • To remove a connection, right click on the connection to remove and select Remove Connection.
  • To switch to a connection, right click on the connection to switch to and select Switch To This Connection.

Query InfluxDB from VS Code

  1. Write your Flux query in a new VS Code file.
  2. Save your Flux script with the .flux extension or set the VS Code Language Mode to Flux.
  3. Press F5 to execute the query.
  4. VS Code displays a list of InfluxDB connection configurations. Select which InfluxDB connection to use to execute the query.
  5. Query results appear in a new tab. If query results do not appear, see Debug Flux queries.

Explore your schema

After you’ve configured an InfluxDB connection, VS Code provides an overview of buckets, measurements, and tags in your InfluxDB organization. Use the InfluxDB pane in VS code to explore your schema.

Explore your InfluxDB schema in VS Code

Debug Flux queries

To view errors returned from Flux script executions, click the Errors and Warnings icons in the bottom left of your VS Code window, and then select the Output tab in the debugging pane.

VS Code errors and warnings

Upgrade the Flux extension

VS Code auto-updates extensions by default, but you are able to disable auto-update. If you disable auto-update, manually update your VS Code Flux extension. After updating the extension, reload your VS Code window (Ctrl+Shift+P, and then Reload Window) to initialize the updated extensions.

Flux extension commands

influxdb.addInstanceAdd Connection

Was this page helpful?

Thank you for your feedback!

Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

Learn more
Contact InfluxData Sales

The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following:

State of the InfluxDB Cloud Serverless documentation

InfluxDB Cloud Serverless documentation is a work in progress.

The new documentation for InfluxDB Cloud Serverless is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.