Sign inGet started

InfluxDB

Available to teams and users on all plans

Deepnote can query your time series data in InfluxDB v2. Follow these docs to create your own notebook to connect to your InfluxDB instance.

1. Duplicate the InfluxDB template

Open the template by following this link ->

spaces%2FtfH69m1V6bYYvquUay8O%2Fuploads%2FuBTyirnZvPcOcczBxtFa%2Fduplicate-notebook.png

Click the "duplicate" button on the top right corner to do this. Once you've got the template in your Deepnote workspace, you can connect it to your InfluxDB instance.

2. Connect to InfluxDB from Deepnote

To connect to SQL from Deepnote, you'll need credentials to connect to a database and the endpoint where that database is located.

Create an InfluxDB token

Follow these instructions to create a token that has permission to access the bucket you're interested in.

Update the token in the notebook

Change the variable INFLUXDB_TOKEN to the token you made in the previous step.

Update the organization and URL details in the notebook

Change the variable INFLUXDB_ORG to the name of your organization, here is how you can find it.

Change the variable INFLUXDB_URL to the URL where your InfluxDB instance is located.

3. Query InfluxDB from Deepnote

The notebook will set up a client object from the InfluxDB Python library. You can create a query client with this object, and query InfluxDB directly to a Pandas dataframe. In the example below, we query InfluxDB's built-in sample data.

query_api = client.query_api()

query = """import "influxdata/influxdb/sample"

sample.data(set: "airSensor")
  |> filter(fn: (r) => r._field == "temperature")
  |> range(start: -45m)
  |> aggregateWindow(every: 1m, fn: mean)"""

# influxdb_client gives us Pandas dataframes out-of-the-box
df = query_api.query_data_frame(query)

df

Running the code above will have Deepnote query the InfluxDB instance, save the result into a dataframe, and visualize it in an interactive table like the one below.

What's next?

Now that you're querying data, you can share it with your team. You can even turn your charts into a shareable dashboard.

For more information on connecting to InfluxDB from Python, you can read the influxdb-client-python docs.