2024-05-31 14:31:27 +00:00
---
id: influxdb
title: InfluxDB
---
ToolJet can connect to InfluxDB databases to read and write data. Use the Token authentication scheme to authenticate to the InfluxDB API. For more info visit [InfluxDB docs ](https://docs.influxdata.com/ ).
2024-09-13 13:09:59 +00:00
< div style = {{paddingTop:'24px'}} >
2024-05-31 14:31:27 +00:00
## Connection
ToolJet connects to InfluxDB using :
- **API Token**
- **Host**
- **Port**
- **Protocol** (HTTP/HTTPS)
:::info
For generating API Token visit [InfluxDB docs ](https://docs.influxdata.com/influxdb/cloud/security/tokens/create-token/ ).
:::
< div style = {{textAlign: ' center ' } } >
2024-09-16 07:13:19 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/influxauth-v3.png" alt = "influx auth" / >
2024-05-31 14:31:27 +00:00
< / div >
2024-09-13 13:09:59 +00:00
< / div >
2024-05-31 14:31:27 +00:00
2024-09-13 13:09:59 +00:00
< div style = {{paddingTop:'24px'}} >
2024-05-31 14:31:27 +00:00
2024-09-13 13:09:59 +00:00
## Supported Queries
2024-05-31 14:31:27 +00:00
2024-09-13 13:09:59 +00:00
- **[Write data](#write-data)**
- **[Query data](#query-data)**
- **[Generate an Abstract Syntax Tree (AST) from a query](#generate-an-abstract-syntax-tree-ast-from-a-query)**
- **[Retrieve query suggestions](#retrieve-query-suggestions)**
- **[Retrieve query suggestions for a branching suggestion](#retrieve-query-suggestions-for-a-branching-suggestion)**
- **[Analyze a Flux query](#analyze-a-flux-query)**
- **[List buckets](#list-buckets)**
- **[Create a bucket](#create-a-bucket)**
- **[Retrieve a bucket](#retrieve-a-bucket)**
- **[Update a bucket](#update-a-bucket)**
- **[Delete a bucket](#delete-a-bucket)**
2024-05-31 14:31:27 +00:00
2024-09-16 07:13:19 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/operations-v3.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
2024-05-31 14:31:27 +00:00
2024-09-13 13:09:59 +00:00
### Write Data
2024-05-31 14:31:27 +00:00
This operation writes data to a bucket.
2024-09-13 13:09:59 +00:00
#### Required Parameters:
2024-05-31 14:31:27 +00:00
- **Bucket**
- **Organization name or ID**
2024-09-13 13:09:59 +00:00
- **Data**
2024-05-31 14:31:27 +00:00
2024-09-13 13:09:59 +00:00
#### Optional Parameters:
2024-05-31 14:31:27 +00:00
- **Precision**
2024-09-13 13:09:59 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/write.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
### Query Data
2024-05-31 14:31:27 +00:00
Retrieves data from InfluxDB buckets.
2024-09-13 13:09:59 +00:00
#### Required Parameters:
2024-05-31 14:31:27 +00:00
- **Organization name or ID**
2024-09-13 13:09:59 +00:00
- **Flux query**
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/query.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
#### Example
2024-05-31 14:31:27 +00:00
2024-09-13 13:09:59 +00:00
```yaml
from(bucket: "sensor_data")
|> range(start: -1h)
|> filter(fn: (r) => r["_measurement"] == "temperature")
```
### Generate an Abstract Syntax Tree (AST) from a Query
2024-05-31 14:31:27 +00:00
This operation analyzes flux query and generates a query specification.
2024-09-13 13:09:59 +00:00
#### Required Parameters:
2024-05-31 14:31:27 +00:00
- **Query**
2024-09-13 13:09:59 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/ast.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
#### Example
```yaml
from(bucket: "website_metrics")
|> range(start: -7d)
|> filter(fn: (r) => r["_measurement"] == "page_views")
|> group(columns: ["url"])
|> sum(column: "_value")
|> sort(columns: ["_value"], desc: true)
```
### Retrieve Query Suggestions
2024-05-31 14:31:27 +00:00
This query retrieve query suggestions.
2024-09-13 13:09:59 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/retrieveQuery.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
### Retrieve Query Suggestions for a Branching Suggestion
2024-05-31 14:31:27 +00:00
This operation retrieve query suggestions for a branching suggestion.
2024-09-13 13:09:59 +00:00
#### Required Parameters:
2024-05-31 14:31:27 +00:00
- **Name**
2024-09-13 13:09:59 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/queryBranch.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
### Analyze a Flux Query
2024-05-31 14:31:27 +00:00
This Analyzes a Flux query.
2024-09-13 13:09:59 +00:00
#### Required Parameters:
2024-05-31 14:31:27 +00:00
- **Query**
2024-09-13 13:09:59 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/fluxQuery.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
#### Example
```yaml
from(bucket: "sensor_data")
|> range(start: -1d)
|> filter(fn: (r) => r["_measurement"] == "humidity")
|> mean(column: "_value")
```
### List Buckets
2024-05-31 14:31:27 +00:00
This operation lists all the buckets in a database.
2024-09-13 13:09:59 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/listBucket.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
### Create a Bucket
This operation creates a bucket in database.
#### Required Parameters:
2024-05-31 14:31:27 +00:00
- **Query**
2024-09-13 13:09:59 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/createBucket.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
#### Example
```yaml
POST http://localhost:8086/api/v2/buckets
Content-Type: application/json
Authorization: Token your_auth_token
{
"name": "new_bucket",
"orgID": "your_org_id",
"retentionRules": [
{
"everySeconds": 3600
}
]
}
```
### Retrieve a Bucket
2024-05-31 14:31:27 +00:00
This operation retrieve a bucket in a database.
2024-09-13 13:09:59 +00:00
#### Required Parameters:
2024-05-31 14:31:27 +00:00
- **Bucket ID**
2024-09-13 13:09:59 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/retrieveBucket.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
### Update a Bucket
This operaition updates the bucket in database.
2024-05-31 14:31:27 +00:00
2024-09-13 13:09:59 +00:00
#### Required Parameters:
2024-05-31 14:31:27 +00:00
- **Bucket ID**
- **Query**
2024-09-13 13:09:59 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/updateBucket.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
#### Example
```yaml
{
"name": "updated_bucket_name",
"retentionRules": [
{
"everySeconds": 7200
}
]
}
```
### Delete a Bucket
2024-05-31 14:31:27 +00:00
2024-09-13 13:09:59 +00:00
This operation delete the bucket in database.
#### Required Parameters:
2024-05-31 14:31:27 +00:00
- **Bucket ID**
2024-09-13 13:09:59 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/influxdb/deleteBucket.png" alt = "influx operations" style = {{marginBottom:'15px'}}/ >
< / div >