Merge branch 'master' into smith/2.7.1/2
commit
4e714a9c5e
|
|
@ -15292,12 +15292,12 @@ paths:
|
|||
|
||||
1. Validates the request and queues the write.
|
||||
2. If queued, responds with _success_ (HTTP `2xx` status code); _error_ otherwise.
|
||||
3. Handles the delete asynchronously and reaches eventual consistency.
|
||||
3. Handles the write asynchronously and reaches eventual consistency.
|
||||
|
||||
To ensure that InfluxDB Cloud handles writes and deletes in the order you request them,
|
||||
To ensure that InfluxDB Cloud handles writes in the order you request them,
|
||||
wait for a success response (HTTP `2xx` status code) before you send the next request.
|
||||
|
||||
Because writes and deletes are asynchronous, your change might not yet be readable
|
||||
Because writes are asynchronous, your change might not yet be readable
|
||||
when you receive the response.
|
||||
|
||||
#### InfluxDB OSS
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ To enable authentication in a cluster, do the following:
|
|||
1. Next, create an admin user (if you haven't already).
|
||||
Using the [`influx` CLI](/enterprise_influxdb/v1.10/tools/influx-cli/),
|
||||
run the following command:
|
||||
```
|
||||
|
||||
```sql
|
||||
CREATE USER admin WITH PASSWORD 'mypassword' WITH ALL PRIVILEGES
|
||||
```
|
||||
1. Restart InfluxDB Enterprise.
|
||||
|
|
|
|||
|
|
@ -150,7 +150,6 @@ For added security, follow these steps to verify the signature of your InfluxDB
|
|||
First, in `/etc/influxdb/influxdb.conf`:
|
||||
|
||||
* Uncomment `hostname` at the top of the file and set it to the full hostname of the data node.
|
||||
* Uncomment `auth-enabled` in the `[http]` section and set it to `true`.
|
||||
* Uncomment `meta-auth-enabled` in the `[meta]` section and set it to `true`.
|
||||
* Uncomment `meta-internal-shared-secret` in the `[meta]` section and set it to a long pass phrase.
|
||||
The internal shared secret is used in JWT authentication for intra-node communication.
|
||||
|
|
@ -194,9 +193,6 @@ hostname="<enterprise-data-0x>"
|
|||
# The bind address used by the HTTP service.
|
||||
# bind-address = ":8086"
|
||||
|
||||
# Determines whether HTTP authentication is enabled.
|
||||
auth-enabled = true # Recommended, but not required
|
||||
|
||||
[...]
|
||||
|
||||
# The JWT auth shared secret to validate requests using JSON web tokens.
|
||||
|
|
@ -297,18 +293,6 @@ If not, there may be artifacts of a previous cluster in the metastore.
|
|||
If you do not see your data nodes in the output, please retry adding them
|
||||
to the cluster.
|
||||
|
||||
## Step 4: Create an admin user
|
||||
|
||||
In [Step 2](#b-edit-the-data-node-configuration-files), you enabled authentication.
|
||||
To access the cluster, you must create at least one admin user.
|
||||
To create an admin user, use the [`influx` CLI](/enterprise_influxdb/v1.10/tools/influx-cli/), and run the following:
|
||||
|
||||
```sql
|
||||
CREATE USER admin WITH PASSWORD '<password>' WITH ALL PRIVILEGES
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Next steps
|
||||
|
||||
Once your data nodes are part of your cluster, do the following:
|
||||
|
|
|
|||
|
|
@ -15,13 +15,15 @@ metadata: [3 / 3]
|
|||
related:
|
||||
- /influxdb/cloud-dedicated/query-data/
|
||||
- /influxdb/cloud-dedicated/query-data/sql/
|
||||
- /influxdb/cloud-dedicated/query-data/execute-queries/
|
||||
- /influxdb/cloud-dedicated/reference/client-libraries/flight-sql/
|
||||
---
|
||||
|
||||
InfluxDB Cloud Dedicated supports multiple query languages:
|
||||
|
||||
- **SQL**: Traditional SQL powered by the [Apache Arrow DataFusion](https://arrow.apache.org/datafusion/)
|
||||
query engine. The supported SQL syntax is similar to PostgreSQL.
|
||||
- **InfluxQL**: A SQL-like query language designed to query time series data from
|
||||
- **InfluxQL**: An SQL-like query language designed to query time series data from
|
||||
InfluxDB.
|
||||
|
||||
This tutorial walks you through the fundamentals of querying data in InfluxDB and
|
||||
|
|
@ -44,17 +46,16 @@ InfluxDB Cloud Dedicated supports many different tools for querying data, includ
|
|||
|
||||
{{< req type="key" text="Covered in this tutorial" color="magenta" >}}
|
||||
|
||||
- [Flight SQL clients](){{< req text="\* " color="magenta" >}}
|
||||
- [InfluxDB client libraries](){{< req text="\* " color="magenta" >}}
|
||||
- [InfluxDB v1 HTTP API](?t=InfluxDB+API#execute-a-sql-query)
|
||||
- [Superset](https://superset.apache.org/)
|
||||
- [Flight SQL clients](?t=Go#execute-an-sql-query){{< req "\* " >}}
|
||||
- [Superset](/influxdb/cloud-dedicated/query-data/execute-queries/flight-sql/superset/)
|
||||
- [Grafana](/influxdb/cloud-dedicated/query-data/tools/grafana/)
|
||||
- [InfluxQL with InfluxDB v1 HTTP API](/influxdb/cloud-dedicated/primers/api/v1/#query-using-the-v1-api)
|
||||
- [Chronograf](/{{< latest "Chronograf" >}}/)
|
||||
|
||||
## SQL query basics
|
||||
|
||||
InfluxDB Cloud's SQL implementation is powered by the [Apache Arrow DataFusion](https://arrow.apache.org/datafusion/)
|
||||
query engine which provides a SQL syntax similar to PostgreSQL.
|
||||
query engine which provides an SQL syntax similar to PostgreSQL.
|
||||
|
||||
{{% note %}}
|
||||
This is a brief introduction to writing SQL queries for InfluxDB.
|
||||
|
|
@ -69,7 +70,7 @@ InfluxDB SQL queries most commonly include the following clauses:
|
|||
measurement or use the wild card alias (`*`) to select all fields and tags
|
||||
from a measurement.
|
||||
- {{< req "\*">}} `FROM`: Identify the measurement to query.
|
||||
If coming from a SQL background, an InfluxDB measurement is the equivalent
|
||||
If coming from an SQL background, an InfluxDB measurement is the equivalent
|
||||
of a relational table.
|
||||
- `WHERE`: Only return data that meets defined conditions such as falling within
|
||||
a time range, containing specific tag values, etc.
|
||||
|
|
@ -162,9 +163,14 @@ ORDER BY room, _time
|
|||
{{% /expand %}}
|
||||
{{< /expand-wrapper >}}
|
||||
|
||||
### Execute a SQL query
|
||||
### Execute an SQL query
|
||||
|
||||
Get started with one of the following tools for querying data stored in an InfluxDB Cloud Dedicated database:
|
||||
|
||||
- **Flight SQL clients**: Use language-specific (Python, Go, etc.) clients to execute queries in your terminal or custom code.
|
||||
- **influx3 CLI**: Send SQL queries from your terminal command-line.
|
||||
- **Grafana**: Query InfluxDB v3 with the [FlightSQL Data Source plugin](https://grafana.com/grafana/plugins/influxdata-flightsql-datasource/) and connect and visualize data.
|
||||
|
||||
Use the **InfluxDB UI**, **`influx` CLI**, or **InfluxDB API** to execute SQL queries.
|
||||
For this example, use the following query to select all the data written to the
|
||||
**get-started** bucket between
|
||||
{{% influxdb/custom-timestamps-span %}}
|
||||
|
|
@ -185,10 +191,67 @@ WHERE
|
|||
|
||||
{{< tabs-wrapper >}}
|
||||
{{% tabs %}}
|
||||
[influx3 CLI](#influx3-cli)
|
||||
[Python](#)
|
||||
[Go](#)
|
||||
{{% /tabs %}}
|
||||
{{% tab-content %}}
|
||||
<!--------------------------- BEGIN influx3 CONTENT --------------------------->
|
||||
|
||||
Query InfluxDB v3 using SQL and the `influx3` CLI, part of the [`InfluxCommunity/pyinflux3`](https://github.com/InfluxCommunity/pyinflux3) community repository.
|
||||
The following steps include setting up a Python virtual environment already
|
||||
covered in [Get started writing data](/influxdb/cloud-dedicated/get-started/write/?t=Python#write-line-protocol-to-influxdb).
|
||||
_If your project's virtual environment is already running, skip to step 3._
|
||||
|
||||
1. Setup your Python virtual environment.
|
||||
Inside of your project directory:
|
||||
|
||||
```sh
|
||||
python -m venv envs/virtual-env
|
||||
```
|
||||
|
||||
2. Activate the virtual environment.
|
||||
|
||||
```sh
|
||||
source ./envs/virtual-env/bin/activate
|
||||
```
|
||||
|
||||
3. Install the following dependencies:
|
||||
|
||||
{{< req type="key" text="Already installed in the [Write data section](/influxdb/cloud-dedicated/get-started/write/?t=Python#write-line-protocol-to-influxdb)" color="magenta" >}}
|
||||
|
||||
- `pyarrow` {{< req text="\*" color="magenta" >}}
|
||||
- `flightsql-dbapi` {{< req text="\*" color="magenta" >}}
|
||||
- `pyinflux3` {{< req text="\*" color="magenta" >}}
|
||||
|
||||
4. Create the `config.json` configuration.
|
||||
|
||||
```sh
|
||||
influx3 config \
|
||||
--name="my-config" \
|
||||
--database="DATABASE_NAME" \
|
||||
--host="cluster-id.influxdb.io" \
|
||||
--token="DATABASE_TOKEN" \
|
||||
--org="INFLUX_ORG_ID"
|
||||
```
|
||||
|
||||
Replace the following:
|
||||
|
||||
- **`DATABASE_NAME`**: the name of the InfluxDB Cloud Dedicated bucket to query
|
||||
- **`DATABASE_TOKEN`**: [Database token](/influxdb/cloud-dedicated/admin/tokens/) with
|
||||
read access to the **get-started** database.
|
||||
- **`INFLUX_ORG_ID`**: InfluxDB organization ID
|
||||
|
||||
5. Enter the `influx3 sql` command and your SQL query statement.
|
||||
|
||||
```sh
|
||||
influx3 sql "SELECT * FROM home WHERE time >= '2022-01-01T08:00:00Z' AND time <= '2022-01-01T20:00:00Z'"
|
||||
```
|
||||
|
||||
`influx3` displays query results in your terminal.
|
||||
|
||||
<!--------------------------- END influx3 CONTENT --------------------------->
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!--------------------------- BEGIN PYTHON CONTENT ---------------------------->
|
||||
|
||||
|
|
@ -235,7 +298,8 @@ _If your project's virtual environment is already running, skip to step 3._
|
|||
Provide the following credentials:
|
||||
|
||||
- **host**: InfluxDB Cloud Dedicated cluster URL (without protocol or trailing slash)
|
||||
- **token**: Database token with read access to the specified database
|
||||
- **token**: [Database token](/influxdb/cloud-dedicated/admin/tokens/) with
|
||||
read access to the **get-started** database.
|
||||
- **database**: Database name to query
|
||||
|
||||
3. Provide the SQL query to execute. In the example below, it's assigned
|
||||
|
|
@ -262,10 +326,13 @@ _If your project's virtual environment is already running, skip to step 3._
|
|||
|
||||
```py
|
||||
from influxdb_client_3 import InfluxDBClient3
|
||||
import os
|
||||
# INFLUX_TOKEN is an environment variable you created for your database READ token
|
||||
TOKEN = os.getenv('INFLUX_TOKEN')
|
||||
|
||||
client = InfluxDBClient3(
|
||||
host="cluster-id.influxdb.io",
|
||||
token="DATABASE_TOKEN",
|
||||
token=TOKEN,
|
||||
database="get-started",
|
||||
)
|
||||
|
||||
|
|
@ -393,6 +460,7 @@ import (
|
|||
|
||||
func dbQuery(ctx context.Context) error {
|
||||
url := "cluster-id.influxdb.io:443"
|
||||
// INFLUX_TOKEN is an environment variable you created for your database READ token
|
||||
token := os.Getenv("INFLUX_TOKEN")
|
||||
database := "get-started"
|
||||
|
||||
|
|
@ -413,7 +481,7 @@ func dbQuery(ctx context.Context) error {
|
|||
}
|
||||
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, "authorization", "Bearer "+token)
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, "iox-namespace-name", database)
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, "database", database)
|
||||
|
||||
// Execute query
|
||||
query := `SELECT
|
||||
|
|
@ -461,8 +529,7 @@ func main() {
|
|||
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
|
||||
Install all the necessary packages and run the program to write the line
|
||||
protocol to your InfluxDB Cloud Dedicated cluster.
|
||||
Install all the necessary packages and run the program to query your InfluxDB Cloud Dedicated cluster.
|
||||
|
||||
```sh
|
||||
go get ./...
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ related:
|
|||
InfluxDB provides many different options for ingesting or writing data, including
|
||||
the following:
|
||||
|
||||
- [InfluxDB HTTP API (v1 and v2)](/influxdb/cloud-serverless/reference/api/)
|
||||
- [InfluxDB HTTP API (v1 and v2)](/influxdb/cloud-dedicated/primers/api/)
|
||||
- [`influx` CLI (v1 and v2)](/influxdb/cloud-dedicated/reference/cli/influx/)
|
||||
- [Telegraf](/{{< latest "telegraf" >}}/)
|
||||
- [InfluxDB client libraries](/influxdb/cloud-dedicated/api-guide/client-libraries/)
|
||||
- [InfluxDB client libraries](/influxdb/cloud-dedicated/reference/client-libraries/)
|
||||
- etc.
|
||||
|
||||
This tutorial walks you through the fundamental of using **line protocol** to write
|
||||
|
|
@ -390,12 +390,13 @@ import (
|
|||
func dbWrite(ctx context.Context) error {
|
||||
// Create write client
|
||||
url := "https://cluster-id.influxdb.io"
|
||||
// INFLUX_TOKEN is an environment variable you assigned to your database token value
|
||||
token := os.Getenv("INFLUX_TOKEN")
|
||||
writeClient := influxdb2.NewClientWithOptions(url, token, influxdb2.DefaultOptions().SetPrecision(time.Second))
|
||||
|
||||
// Define write API
|
||||
org := "ignored"
|
||||
bucket := "DATABASE_NAME"
|
||||
bucket := "get-started"
|
||||
writeAPI := writeClient.WriteAPIBlocking(org, bucket)
|
||||
|
||||
line := [...]string{
|
||||
|
|
@ -447,11 +448,6 @@ func main() {
|
|||
}
|
||||
```
|
||||
|
||||
Replace the following:
|
||||
|
||||
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with sufficient permissions to the database
|
||||
|
||||
Run the following command to install the necessary packages:
|
||||
|
||||
```sh
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ list_code_example: |
|
|||
|
||||
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||
metadata={'database': 'INFLUX_DATABASE'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
info = client.execute("SELECT * FROM home")
|
||||
|
|
@ -207,7 +207,7 @@ and the _DB API 2_ interface to instantiate a Flight SQL client configured for a
|
|||
# Instantiate a FlightSQLClient configured for your database
|
||||
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||
metadata={'database': 'INFLUX_DATABASE'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
```
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ from flightsql import FlightSQLClient
|
|||
|
||||
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||
metadata={'database': 'INFLUX_DATABASE'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
# Execute the query
|
||||
|
|
@ -271,7 +271,7 @@ from flightsql import FlightSQLClient
|
|||
# Instantiate a FlightSQLClient configured for a database
|
||||
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||
metadata={'database': 'INFLUX_DATABASE'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
# Execute the query to retrieve FlightInfo
|
||||
|
|
|
|||
|
|
@ -214,17 +214,17 @@ With Superset running, you're ready to [log in](#log-in-to-superset) and set up
|
|||
|
||||
**Query parameters**
|
||||
|
||||
- **`?iox-namespace-name`**: URL-encoded InfluxDB [database name](/influxdb/cloud-dedicated/admin/databases/list/)
|
||||
- **`?database`**: URL-encoded InfluxDB [database name](/influxdb/cloud-dedicated/admin/databases/list/)
|
||||
- **`?token`**: InfluxDB [API token](/influxdb/cloud-dedicated/get-started/setup/) with `READ` access to the specified database
|
||||
|
||||
{{< code-callout "<(domain|port|database-name|token)>" >}}
|
||||
{{< code-callout "cluster-id\.influxdb\.io|443|example-database|example-token" >}}
|
||||
```sh
|
||||
# Syntax
|
||||
datafusion+flightsql://<domain>:<port>?iox-namespace-name=<database-name>&token=<token>
|
||||
datafusion+flightsql://<domain>:<port>?database=<database-name>&token=<token>
|
||||
|
||||
# Example
|
||||
datafusion+flightsql://cluster-id.influxdb.io:443?iox-namespace-name=example-database&token=example-token
|
||||
datafusion+flightsql://cluster-id.influxdb.io:443?database=example-database&token=example-token
|
||||
```
|
||||
{{< /code-callout >}}
|
||||
{{< /code-callout >}}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ list_code_example: |
|
|||
```
|
||||
---
|
||||
|
||||
A SQL query that aggregates data includes the following clauses:
|
||||
An SQL query that aggregates data includes the following clauses:
|
||||
|
||||
{{< req type="key" >}}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ list_code_example: |
|
|||
---
|
||||
|
||||
The InfluxDB SQL implementation is powered by the [Apache Arrow DataFusion](https://arrow.apache.org/datafusion/)
|
||||
query engine which provides a SQL syntax similar to other relational query languages.
|
||||
query engine which provides an SQL syntax similar to other relational query languages.
|
||||
|
||||
A basic SQL query that queries data from InfluxDB most commonly includes the
|
||||
following clauses:
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ Use the **InfluxDB** core Grafana plugin to query data with **InfluxQL**.
|
|||
|
||||
- [Install Grafana or login to Grafana Cloud](#install-grafana-or-login-to-grafana-cloud)
|
||||
- [Install the FlightSQL plugin](#install-the-flightsql-plugin)
|
||||
- [Use grafana-cli](#use-grafana-cli)
|
||||
- [Use the Grafana UI](#use-the-grafana-ui)
|
||||
- [Create a datasource](#create-a-datasource)
|
||||
- [Query InfluxDB with Grafana](#query-influxdb-with-grafana)
|
||||
- [Build visualizations with Grafana](#build-visualizations-with-grafana)
|
||||
|
|
@ -139,7 +141,7 @@ query InfluxDB Cloud Dedicated:
|
|||
|
||||
InfluxDB Cloud Serverless requires your **database name**:
|
||||
|
||||
- **Key**: `iox-namespace-name`
|
||||
- **Key**: `database`
|
||||
- **Value**: Database name
|
||||
|
||||
7. Click **Save & test**.
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ The following steps use Python, `flightsql-dbapi`, and `pyarrow` to query Influx
|
|||
|
||||
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||
metadata={'database': 'INFLUX_DATABASE'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
info = client.execute("SELECT * FROM home")
|
||||
|
|
@ -127,7 +127,7 @@ import pandas
|
|||
|
||||
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||
metadata={'database': 'INFLUX_DATABASE'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
info = client.execute("SELECT * FROM home")
|
||||
|
|
@ -155,7 +155,7 @@ import pandas
|
|||
|
||||
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||
metadata={'database': 'INFLUX_DATABASE'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
info = client.execute("SELECT * FROM home")
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ The following example shows how to use Python with `flightsql-dbapi` and `pyarro
|
|||
# Instantiate a FlightSQLClient configured for a database
|
||||
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||
metadata={'database': 'INFLUX_DATABASE'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
# Execute the query to retrieve FlightInfo
|
||||
|
|
@ -107,7 +107,7 @@ from flightsql import FlightSQLClient
|
|||
|
||||
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||
metadata={'database': 'INFLUX_DATABASE'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
info = client.execute('SELECT * FROM home')
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ weight: 201
|
|||
---
|
||||
|
||||
The [Go Flight SQL client](https://pkg.go.dev/github.com/apache/arrow/go/v12/arrow/flight/flightsql) integrates with golang scripts and applications to query data stored in an InfluxDB Cloud Dedicated database.
|
||||
See the [example](/influxdb/cloud-dedicated/get-started/query/?t=Go#execute-a-sql-query).
|
||||
See the [example](/influxdb/cloud-dedicated/get-started/query/?t=Go#execute-an-sql-query).
|
||||
|
||||
For more information, see the [Go client README on GitHub](https://github.com/influxdata/influxdb-client-go).
|
||||
|
|
|
|||
|
|
@ -122,6 +122,6 @@ func main() {
|
|||
## Query data from InfluxDB with Go
|
||||
The InfluxDB v2 Go client cannot query InfluxDB Cloud Dedicated.
|
||||
To query your dedicated instance, use the [Go Flight SQL client](https://pkg.go.dev/github.com/apache/arrow/go/v12/arrow/flight/flightsql).
|
||||
For an example, see [Get started querying data](/influxdb/cloud-dedicated/get-started/query/?t=Go#execute-a-sql-query).
|
||||
For an example, see [Get started querying data](/influxdb/cloud-dedicated/get-started/query/?t=Go#execute-an-sql-query).
|
||||
|
||||
For more information, see the [Go client README on GitHub](https://github.com/influxdata/influxdb-client-go).
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ title: Get started querying data
|
|||
seotitle: Query data | Get started with InfluxDB
|
||||
list_title: Query data
|
||||
description: >
|
||||
Get started querying data in InfluxDB by learning about Flux and InfluxQL and
|
||||
using tools like the InfluxDB UI, `influx` CLI, and InfluxDB API.
|
||||
Get started querying data in InfluxDB by learning about SQL, InfluxQL, and Flux and
|
||||
using tools like the InfluxDB UI, `influx` CLI, InfluxDB API, and Flight SQL clients.
|
||||
menu:
|
||||
influxdb_cloud_serverless:
|
||||
name: Query data
|
||||
|
|
@ -16,6 +16,7 @@ related:
|
|||
- /influxdb/cloud-serverless/query-data/
|
||||
- /influxdb/cloud-serverless/query-data/sql/
|
||||
- /influxdb/cloud-serverless/query-data/execute-queries/
|
||||
- /influxdb/cloud-serverless/reference/client-libraries/flight-sql/
|
||||
---
|
||||
|
||||
InfluxDB Cloud Serverless supports multiple query languages:
|
||||
|
|
@ -29,6 +30,11 @@ InfluxDB Cloud Serverless supports multiple query languages:
|
|||
|
||||
This tutorial walks you through the fundamentals of querying data in InfluxDB and
|
||||
**focuses on using SQL** to query your time series data.
|
||||
The InfluxDB SQL implementation is built using [Arrow Flight SQL](https://arrow.apache.org/docs/format/FlightSql.html),
|
||||
a protocol for interacting with SQL databases using the Arrow in-memory format and the
|
||||
[Flight RPC](https://arrow.apache.org/docs/format/Flight.html) framework.
|
||||
It leverages the performance of [Apache Arrow](https://arrow.apache.org/) with
|
||||
the simplicity of SQL.
|
||||
<!-- For information about using InfluxQL and Flux, see
|
||||
[Query data in InfluxDB](/influxdb/cloud-serverless/query-data/). -->
|
||||
|
||||
|
|
@ -39,17 +45,18 @@ The examples in this section of the tutorial query the [**get-started** bucket](
|
|||
|
||||
## Tools to execute queries
|
||||
|
||||
InfluxDB supports many different tools for querying data, including:
|
||||
InfluxDB Cloud Serverless supports many different tools for querying data, including:
|
||||
|
||||
{{< req type="key" text="Covered in this tutorial" >}}
|
||||
|
||||
- [InfluxDB user interface (UI)](?t=InfluxDB+UI#execute-a-sql-query){{< req "\* " >}}
|
||||
- [InfluxDB HTTP API](?t=InfluxDB+API#execute-a-sql-query){{< req "\* " >}}
|
||||
- [`influx` CLI](?t=influx+CLI#execute-a-sql-query){{< req "\* " >}}
|
||||
- [Superset](https://superset.apache.org/)
|
||||
- [Grafana](/influxdb/cloud-serverless/tools/grafana/)
|
||||
- [Flight SQL clients](?t=Go#execute-an-sql-query){{< req "\* " >}}
|
||||
- [InfluxDB user interface (UI)](?t=InfluxDB+UI#execute-an-sql-query){{< req "\* " >}}
|
||||
- [`influx3` data CLI](?t=influx3+CLI#execute-an-sql-query){{< req "\* " >}}
|
||||
- [InfluxDB HTTP API](?t=InfluxDB+API#execute-an-sql-query){{< req "\* " >}}
|
||||
- [`influx` CLI](?t=influx+CLI#execute-an-sql-query){{< req "\* " >}}
|
||||
- [Superset](/influxdb/cloud-serverless/query-data/execute-queries/flight-sql/superset/)
|
||||
- [Grafana](/influxdb/cloud-serverless/query-data/tools/grafana/)
|
||||
- [Chronograf](/{{< latest "Chronograf" >}}/)
|
||||
- InfluxDB client libraries
|
||||
|
||||
## SQL query basics
|
||||
|
||||
|
|
@ -162,10 +169,16 @@ ORDER BY room, _time
|
|||
{{% /expand %}}
|
||||
{{< /expand-wrapper >}}
|
||||
|
||||
### Execute an SQL query
|
||||
|
||||
### Execute a SQL query
|
||||
Get started with one of the following tools for querying data stored in an InfluxDB Cloud Serverless bucket:
|
||||
|
||||
- **InfluxDB UI**: View your schema, build queries using the query editor, and generate data visualizations.
|
||||
- **Flight SQL clients**: Use language-specific (Python, Go, etc.) clients to execute queries in your terminal or custom code.
|
||||
- **influx3 CLI**: Send SQL queries from your terminal command-line.
|
||||
- **Grafana**: Query InfluxDB v3 with the [FlightSQL Data Source plugin](https://grafana.com/grafana/plugins/influxdata-flightsql-datasource/) and connect and visualize data.
|
||||
- **`influx` CLI**, **InfluxDB API**, and **InfluxDB API v2 client libraries**: Use the InfluxDB `/api/v2/query` endpoint and Flux to execute SQL.
|
||||
|
||||
Use the **InfluxDB UI**, **`influx` CLI**, or **InfluxDB API** to execute SQL queries.
|
||||
For this example, use the following query to select all the data written to the
|
||||
**get-started** bucket between
|
||||
{{% influxdb/custom-timestamps-span %}}
|
||||
|
|
@ -187,21 +200,24 @@ WHERE
|
|||
{{< tabs-wrapper >}}
|
||||
{{% tabs %}}
|
||||
[InfluxDB UI](#influxdb-ui)
|
||||
[influx3 CLI](#influx3-cli)
|
||||
[Python](#)
|
||||
[Go](#)
|
||||
[influx CLI](#influx-cli)
|
||||
[InfluxDB API](#influxdb-http-api)
|
||||
{{% /tabs %}}
|
||||
|
||||
{{% tab-content %}}
|
||||
<!--------------------------- BEGIN FLUX UI CONTENT --------------------------->
|
||||
<!--------------------------- BEGIN UI CONTENT --------------------------->
|
||||
|
||||
1. Go to
|
||||
{{% oss-only %}}[localhost:8086](http://localhost:8086){{% /oss-only %}}
|
||||
{{% cloud-only %}}[cloud2.influxdata.com](https://cloud2.influxdata.com){{% /cloud-only %}}
|
||||
in a browser to log in and access the InfluxDB UI.
|
||||
|
||||
2. In the left navigation bar, click **Data Explorer**.
|
||||
2. In the side navigation menu, click **Data Explorer**.
|
||||
|
||||
{{< nav-icon "data-explorer" "v4" >}}
|
||||
{{< nav-icon "data-explorer" "v4" >}}
|
||||
|
||||
3. In the schema browser on the left, select the **get-started** bucket from the
|
||||
**bucket** drop-down menu.
|
||||
|
|
@ -212,11 +228,552 @@ WHERE
|
|||
|
||||
5. Click **{{< icon "play" >}} {{% caps %}}Run{{% /caps %}}**.
|
||||
|
||||
Results are displayed under the text editor.
|
||||
Results are displayed under the query editor.
|
||||
|
||||
See [Query in the Data Explorer](/influxdb/cloud-serverless/query-data/execute-queries/data-explorer/) to learn more.
|
||||
|
||||
<!---------------------------- END FLUX UI CONTENT ---------------------------->
|
||||
<!---------------------------- END UI CONTENT ---------------------------->
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!--------------------------- BEGIN influx3 CONTENT --------------------------->
|
||||
|
||||
Query InfluxDB v3 using SQL and the `influx3` CLI, part of the [`InfluxCommunity/pyinflux3`](https://github.com/InfluxCommunity/pyinflux3) community repository.
|
||||
The following steps include setting up a Python virtual environment already
|
||||
covered in [Get started writing data](/influxdb/cloud-serverless/get-started/write/?t=Python#write-line-protocol-to-influxdb).
|
||||
_If your project's virtual environment is already running, skip to step 3._
|
||||
|
||||
1. Setup your Python virtual environment.
|
||||
Inside of your project directory:
|
||||
|
||||
```sh
|
||||
python -m venv envs/virtual-env
|
||||
```
|
||||
|
||||
2. Activate the virtual environment.
|
||||
|
||||
```sh
|
||||
source ./envs/virtual-env/bin/activate
|
||||
```
|
||||
|
||||
3. Install the following dependencies:
|
||||
|
||||
{{< req type="key" text="Already installed in the [Write data section](/influxdb/cloud-serverless/get-started/write/?t=Python#write-line-protocol-to-influxdb)" color="magenta" >}}
|
||||
|
||||
- `pyarrow` {{< req text="\*" color="magenta" >}}
|
||||
- `flightsql-dbapi` {{< req text="\*" color="magenta" >}}
|
||||
- `pyinflux3` {{< req text="\*" color="magenta" >}}
|
||||
|
||||
4. Create the `config.json` configuration.
|
||||
|
||||
```sh
|
||||
influx3 config \
|
||||
--name="my-config" \
|
||||
--database="BUCKET_NAME" \
|
||||
--host="cloud2.influxdata.com" \
|
||||
--token="INFLUX_API_READ_TOKEN" \
|
||||
--org="INFLUX_ORG_ID"
|
||||
```
|
||||
|
||||
Replace the following:
|
||||
|
||||
- **`BUCKET_NAME`**: the name of the InfluxDB Cloud Serverless bucket to query
|
||||
- **`INFLUX_API_READ_TOKEN`**: InfluxDB API token with _read_ access to the **get-started** bucket
|
||||
- **`INFLUX_ORG_ID`**: InfluxDB organization ID
|
||||
|
||||
5. Enter the `influx3 sql` command and your SQL query statement.
|
||||
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
```sh
|
||||
influx3 sql "SELECT * FROM home WHERE time >= '2022-01-01T08:00:00Z' AND time <= '2022-01-01T20:00:00Z'"
|
||||
```
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
|
||||
`influx3` displays query results in your terminal.
|
||||
|
||||
<!--------------------------- END influx3 CONTENT --------------------------->
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!--------------------------- BEGIN PYTHON CONTENT ---------------------------->
|
||||
|
||||
To query data from InfluxDB Cloud Serverless using Python, use the
|
||||
[`pyinflux3` module](https://github.com/InfluxCommunity/pyinflux3).
|
||||
The following steps include setting up a Python virtual environment already
|
||||
covered in [Get started writing data](/influxdb/cloud-serverless/get-started/write/?t=Python#write-line-protocol-to-influxdb).
|
||||
_If your project's virtual environment is already running, skip to step 3._
|
||||
|
||||
1. Setup your Python virtual environment.
|
||||
Inside of your project directory:
|
||||
|
||||
```sh
|
||||
python -m venv envs/virtual-env
|
||||
```
|
||||
|
||||
2. Activate the virtual environment.
|
||||
|
||||
```sh
|
||||
source ./envs/virtual-env/bin/activate
|
||||
```
|
||||
|
||||
3. Install the following dependencies:
|
||||
|
||||
{{< req type="key" text="Already installed in the [Write data section](/influxdb/cloud-serverless/get-started/write/?t=Python#write-line-protocol-to-influxdb)" color="magenta" >}}
|
||||
|
||||
- `pyarrow` {{< req text="\*" color="magenta" >}}
|
||||
- `flightsql-dbapi` {{< req text="\*" color="magenta" >}}
|
||||
- `pyinflux3` {{< req text="\*" color="magenta" >}}
|
||||
- `pandas`
|
||||
- `tabulate` _(to return formatted tables)_
|
||||
|
||||
```sh
|
||||
pip install pandas tabulate
|
||||
```
|
||||
|
||||
4. Build your python script to query your InfluxDB bucket.
|
||||
_These can be structured as a Python script or executed in a `python` shell._
|
||||
|
||||
1. Import the `InfluxDBClient3` constructor from the `influxdb_client_3` module.
|
||||
|
||||
2. Use the `InfluxDBClient3` constructor to instantiate an InfluxDB Client.
|
||||
The example below assigns it to the `client` variable.
|
||||
Provide the following credentials:
|
||||
|
||||
- **host**: InfluxDB Cloud Serverless region hostname (URL without protocol or trailing slash)
|
||||
- **token**: InfluxDB API token with _read_ access to the specified bucket.
|
||||
_For security reasons, we recommend setting this as an environment
|
||||
variable rather than including the raw token string._
|
||||
- **database**: the name of the InfluxDB Cloud Serverless bucket to query
|
||||
|
||||
3. Provide the SQL query to execute. In the example below, it's assigned
|
||||
to the `query`variable.
|
||||
|
||||
4. Use the `client.query` method to query data in the **get-started**
|
||||
database and return an Arrow table. Assign the return value to the
|
||||
`table` variable. Provide the following:
|
||||
|
||||
- **sql_query** SQL query string to execute
|
||||
|
||||
5. Use [`read_all`](https://docs.python.org/3/library/telnetlib.html#telnetlib.Telnet.read_all)
|
||||
to read the data from InfluxDB and return an Arrow table.
|
||||
|
||||
6. Use [`to_pandas`](https://arrow.apache.org/docs/python/generated/pyarrow.Table.html#pyarrow.Table.to_pandas)
|
||||
to convert the Arrow table to a pandas DataFrame.
|
||||
|
||||
7. Use [`to_markdown`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_markdown.html)
|
||||
to convert the DataFrame to a markdown table.
|
||||
|
||||
8. Use `print` to print out the markdown table.
|
||||
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
|
||||
```py
|
||||
from influxdb_client_3 import InfluxDBClient3
|
||||
import os
|
||||
|
||||
# INFLUX_TOKEN is an environment variable you created for your API token
|
||||
TOKEN = os.getenv('INFLUX_TOKEN')
|
||||
|
||||
client = InfluxDBClient3(
|
||||
host="cloud2.influxdata.com",
|
||||
token=TOKEN,
|
||||
database="get-started",
|
||||
)
|
||||
|
||||
sql = '''
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
home
|
||||
WHERE
|
||||
time >= '2022-01-01T08:00:00Z'
|
||||
AND time <= '2022-01-01T20:00:00Z'
|
||||
'''
|
||||
|
||||
table = client.query(sql_query=sql)
|
||||
reader = table.read_all()
|
||||
print(reader.to_pandas().to_markdown())
|
||||
```
|
||||
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
|
||||
{{< expand-wrapper >}}
|
||||
{{% expand "View returned markdown table" %}}
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
|
||||
| | co | hum | room | temp | time |
|
||||
|---:|-----:|------:|:------------|-------:|:--------------------|
|
||||
| 0 | 0 | 35.9 | Kitchen | 21 | 2022-01-01 08:00:00 |
|
||||
| 1 | 0 | 36.2 | Kitchen | 23 | 2022-01-01 09:00:00 |
|
||||
| 2 | 0 | 36.1 | Kitchen | 22.7 | 2022-01-01 10:00:00 |
|
||||
| 3 | 0 | 36 | Kitchen | 22.4 | 2022-01-01 11:00:00 |
|
||||
| 4 | 0 | 36 | Kitchen | 22.5 | 2022-01-01 12:00:00 |
|
||||
| 5 | 1 | 36.5 | Kitchen | 22.8 | 2022-01-01 13:00:00 |
|
||||
| 6 | 1 | 36.3 | Kitchen | 22.8 | 2022-01-01 14:00:00 |
|
||||
| 7 | 3 | 36.2 | Kitchen | 22.7 | 2022-01-01 15:00:00 |
|
||||
| 8 | 7 | 36 | Kitchen | 22.4 | 2022-01-01 16:00:00 |
|
||||
| 9 | 9 | 36 | Kitchen | 22.7 | 2022-01-01 17:00:00 |
|
||||
| 10 | 18 | 36.9 | Kitchen | 23.3 | 2022-01-01 18:00:00 |
|
||||
| 11 | 22 | 36.6 | Kitchen | 23.1 | 2022-01-01 19:00:00 |
|
||||
| 12 | 26 | 36.5 | Kitchen | 22.7 | 2022-01-01 20:00:00 |
|
||||
| 13 | 0 | 35.9 | Living Room | 21.1 | 2022-01-01 08:00:00 |
|
||||
| 14 | 0 | 35.9 | Living Room | 21.4 | 2022-01-01 09:00:00 |
|
||||
| 15 | 0 | 36 | Living Room | 21.8 | 2022-01-01 10:00:00 |
|
||||
| 16 | 0 | 36 | Living Room | 22.2 | 2022-01-01 11:00:00 |
|
||||
| 17 | 0 | 35.9 | Living Room | 22.2 | 2022-01-01 12:00:00 |
|
||||
| 18 | 0 | 36 | Living Room | 22.4 | 2022-01-01 13:00:00 |
|
||||
| 19 | 0 | 36.1 | Living Room | 22.3 | 2022-01-01 14:00:00 |
|
||||
| 20 | 1 | 36.1 | Living Room | 22.3 | 2022-01-01 15:00:00 |
|
||||
| 21 | 4 | 36 | Living Room | 22.4 | 2022-01-01 16:00:00 |
|
||||
| 22 | 5 | 35.9 | Living Room | 22.6 | 2022-01-01 17:00:00 |
|
||||
| 23 | 9 | 36.2 | Living Room | 22.8 | 2022-01-01 18:00:00 |
|
||||
| 24 | 14 | 36.3 | Living Room | 22.5 | 2022-01-01 19:00:00 |
|
||||
| 25 | 17 | 36.4 | Living Room | 22.2 | 2022-01-01 20:00:00 |
|
||||
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
{{% /expand %}}
|
||||
{{< /expand-wrapper >}}
|
||||
|
||||
<!---------------------------- END PYTHON CONTENT ----------------------------->
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!----------------------------- BEGIN GO CONTENT ------------------------------>
|
||||
|
||||
1. In the `influxdb_go_client` directory you created in the
|
||||
[Write data section](/influxdb/cloud-serverless/get-started/write/?t=Go#write-line-protocol-to-influxdb),
|
||||
create a new file named `query.go`.
|
||||
|
||||
2. In `query.go`:
|
||||
|
||||
1. Import the following packages:
|
||||
|
||||
- `context`
|
||||
- `crypto/x509`
|
||||
- `encoding/json`
|
||||
- `fmt`
|
||||
- `os`
|
||||
- `github.com/apache/arrow/go/v12/arrow/flight/flightsql`
|
||||
- `google.golang.org/grpc`
|
||||
- `google.golang.org/grpc/credentials`
|
||||
- `google.golang.org/grpc/metadata`
|
||||
|
||||
2. Create a `dbQuery` function. In `dbQuery, define the following
|
||||
variables:
|
||||
|
||||
- **url**: InfluxDB Cloud Serverless region hostname and port (`:443`) _(no protocol)_
|
||||
- **token**: InfluxDB API token with _read_ access to the specified bucket.
|
||||
_For security reasons, we recommend setting this as an environment
|
||||
variable rather than including the raw token string._
|
||||
- **database**: the name of the InfluxDB Cloud Serverless bucket to query
|
||||
|
||||
3. In the `dbQuery` function, create a gRPC transport for communicating
|
||||
with InfluxDB Cloud Serverless over the _gRPC+TLS_ protocol.
|
||||
|
||||
4. Use `flightsql.NewClient` to create a new Flight SQL client.
|
||||
|
||||
5. Append the following key-value pairs to the outgoing context:
|
||||
|
||||
- **authorization**: Bearer <INFLUX_TOKEN>
|
||||
- **database-name**: Database name
|
||||
|
||||
6. Define the query to execute.
|
||||
|
||||
7. Create a reader to read the Arrow table returned by the query and print
|
||||
the results as JSON.
|
||||
|
||||
8. Create a `main` function that executes the `dbQuery` function.
|
||||
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/x509"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/apache/arrow/go/v12/arrow/flight/flightsql"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
func dbQuery(ctx context.Context) error {
|
||||
url := "cloud2.influxdata.com:443"
|
||||
// INFLUX_TOKEN is an environment variable you created for your API token
|
||||
token := os.Getenv("INFLUX_TOKEN")
|
||||
database := "get-started"
|
||||
|
||||
// Create a gRPC transport
|
||||
pool, err := x509.SystemCertPool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("x509: %s", err)
|
||||
}
|
||||
transport := grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(pool, ""))
|
||||
opts := []grpc.DialOption{
|
||||
transport,
|
||||
}
|
||||
|
||||
// Create query client
|
||||
client, err := flightsql.NewClient(url, nil, nil, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("flightsql: %s", err)
|
||||
}
|
||||
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, "authorization", "Bearer "+token)
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, "database", database)
|
||||
|
||||
// Execute query
|
||||
query := `SELECT
|
||||
*
|
||||
FROM
|
||||
home
|
||||
WHERE
|
||||
time >= '2022-01-01T08:00:00Z'
|
||||
AND time <= '2022-01-01T20:00:00Z'`
|
||||
|
||||
info, err := client.Execute(ctx, query)
|
||||
if err != nil {
|
||||
return fmt.Errorf("flightsql flight info: %s", err)
|
||||
}
|
||||
reader, err := client.DoGet(ctx, info.Endpoint[0].Ticket)
|
||||
if err != nil {
|
||||
return fmt.Errorf("flightsql do get: %s", err)
|
||||
}
|
||||
|
||||
// Print results as JSON
|
||||
for reader.Next() {
|
||||
record := reader.Record()
|
||||
b, err := json.MarshalIndent(record, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("RECORD BATCH")
|
||||
fmt.Println(string(b))
|
||||
|
||||
if err := reader.Err(); err != nil {
|
||||
return fmt.Errorf("flightsql reader: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := dbQuery(context.Background()); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
|
||||
Install all the necessary packages and run the program to query InfluxDB Cloud Serverless.
|
||||
|
||||
```sh
|
||||
go get ./...
|
||||
go run ./query.go
|
||||
```
|
||||
|
||||
{{< expand-wrapper >}}
|
||||
{{% expand "View program output" %}}
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
|
||||
```json
|
||||
RECORD BATCH
|
||||
[
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 35.9,
|
||||
"room": "Kitchen",
|
||||
"temp": 21,
|
||||
"time": "2022-01-01 08:00:00"
|
||||
},
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 36.2,
|
||||
"room": "Kitchen",
|
||||
"temp": 23,
|
||||
"time": "2022-01-01 09:00:00"
|
||||
},
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 36.1,
|
||||
"room": "Kitchen",
|
||||
"temp": 22.7,
|
||||
"time": "2022-01-01 10:00:00"
|
||||
},
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 36,
|
||||
"room": "Kitchen",
|
||||
"temp": 22.4,
|
||||
"time": "2022-01-01 11:00:00"
|
||||
},
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 36,
|
||||
"room": "Kitchen",
|
||||
"temp": 22.5,
|
||||
"time": "2022-01-01 12:00:00"
|
||||
},
|
||||
{
|
||||
"co": 1,
|
||||
"hum": 36.5,
|
||||
"room": "Kitchen",
|
||||
"temp": 22.8,
|
||||
"time": "2022-01-01 13:00:00"
|
||||
},
|
||||
{
|
||||
"co": 1,
|
||||
"hum": 36.3,
|
||||
"room": "Kitchen",
|
||||
"temp": 22.8,
|
||||
"time": "2022-01-01 14:00:00"
|
||||
},
|
||||
{
|
||||
"co": 3,
|
||||
"hum": 36.2,
|
||||
"room": "Kitchen",
|
||||
"temp": 22.7,
|
||||
"time": "2022-01-01 15:00:00"
|
||||
},
|
||||
{
|
||||
"co": 7,
|
||||
"hum": 36,
|
||||
"room": "Kitchen",
|
||||
"temp": 22.4,
|
||||
"time": "2022-01-01 16:00:00"
|
||||
},
|
||||
{
|
||||
"co": 9,
|
||||
"hum": 36,
|
||||
"room": "Kitchen",
|
||||
"temp": 22.7,
|
||||
"time": "2022-01-01 17:00:00"
|
||||
},
|
||||
{
|
||||
"co": 18,
|
||||
"hum": 36.9,
|
||||
"room": "Kitchen",
|
||||
"temp": 23.3,
|
||||
"time": "2022-01-01 18:00:00"
|
||||
},
|
||||
{
|
||||
"co": 22,
|
||||
"hum": 36.6,
|
||||
"room": "Kitchen",
|
||||
"temp": 23.1,
|
||||
"time": "2022-01-01 19:00:00"
|
||||
},
|
||||
{
|
||||
"co": 26,
|
||||
"hum": 36.5,
|
||||
"room": "Kitchen",
|
||||
"temp": 22.7,
|
||||
"time": "2022-01-01 20:00:00"
|
||||
},
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 35.9,
|
||||
"room": "Living Room",
|
||||
"temp": 21.1,
|
||||
"time": "2022-01-01 08:00:00"
|
||||
},
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 35.9,
|
||||
"room": "Living Room",
|
||||
"temp": 21.4,
|
||||
"time": "2022-01-01 09:00:00"
|
||||
},
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 36,
|
||||
"room": "Living Room",
|
||||
"temp": 21.8,
|
||||
"time": "2022-01-01 10:00:00"
|
||||
},
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 36,
|
||||
"room": "Living Room",
|
||||
"temp": 22.2,
|
||||
"time": "2022-01-01 11:00:00"
|
||||
},
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 35.9,
|
||||
"room": "Living Room",
|
||||
"temp": 22.2,
|
||||
"time": "2022-01-01 12:00:00"
|
||||
},
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 36,
|
||||
"room": "Living Room",
|
||||
"temp": 22.4,
|
||||
"time": "2022-01-01 13:00:00"
|
||||
},
|
||||
{
|
||||
"co": 0,
|
||||
"hum": 36.1,
|
||||
"room": "Living Room",
|
||||
"temp": 22.3,
|
||||
"time": "2022-01-01 14:00:00"
|
||||
},
|
||||
{
|
||||
"co": 1,
|
||||
"hum": 36.1,
|
||||
"room": "Living Room",
|
||||
"temp": 22.3,
|
||||
"time": "2022-01-01 15:00:00"
|
||||
},
|
||||
{
|
||||
"co": 4,
|
||||
"hum": 36,
|
||||
"room": "Living Room",
|
||||
"temp": 22.4,
|
||||
"time": "2022-01-01 16:00:00"
|
||||
},
|
||||
{
|
||||
"co": 5,
|
||||
"hum": 35.9,
|
||||
"room": "Living Room",
|
||||
"temp": 22.6,
|
||||
"time": "2022-01-01 17:00:00"
|
||||
},
|
||||
{
|
||||
"co": 9,
|
||||
"hum": 36.2,
|
||||
"room": "Living Room",
|
||||
"temp": 22.8,
|
||||
"time": "2022-01-01 18:00:00"
|
||||
},
|
||||
{
|
||||
"co": 14,
|
||||
"hum": 36.3,
|
||||
"room": "Living Room",
|
||||
"temp": 22.5,
|
||||
"time": "2022-01-01 19:00:00"
|
||||
},
|
||||
{
|
||||
"co": 17,
|
||||
"hum": 36.4,
|
||||
"room": "Living Room",
|
||||
"temp": 22.2,
|
||||
"time": "2022-01-01 20:00:00"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
{{% /expand %}}
|
||||
{{< /expand-wrapper >}}
|
||||
|
||||
<!------------------------------ END GO CONTENT ------------------------------->
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!-------------------------- BEGIN FLUX CLI CONTENT --------------------------->
|
||||
|
|
@ -344,7 +901,6 @@ curl --request POST \
|
|||
```
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
|
||||
|
||||
{{% note %}}
|
||||
The InfluxDB `/api/v2/query` endpoint returns query results in
|
||||
[annotated CSV](/influxdb/cloud-serverless/reference/syntax/annotated-csv/).
|
||||
|
|
|
|||
|
|
@ -143,6 +143,8 @@ line protocol above to InfluxDB.
|
|||
[InfluxDB UI](#)
|
||||
[influx CLI](#)
|
||||
[InfluxDB API](#)
|
||||
[Python](#)
|
||||
[Go](#)
|
||||
{{% /tabs %}}
|
||||
|
||||
{{% tab-content %}}
|
||||
|
|
@ -289,6 +291,255 @@ home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200
|
|||
{{% /influxdb/custom-timestamps %}}
|
||||
<!------------------------------ END API CONTENT ------------------------------>
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!---------------------------- BEGIN PYTHON CONTENT --------------------------->
|
||||
|
||||
To write data to InfluxDB Cloud Serverless using Python, use the
|
||||
[`pyinflux3` module](https://github.com/InfluxCommunity/pyinflux3).
|
||||
The following steps include setting up a Python virtual environment to scope
|
||||
dependencies to your current project.
|
||||
|
||||
1. Setup your Python virtual environment.
|
||||
Inside of your project directory:
|
||||
|
||||
```sh
|
||||
python -m venv envs/virtual-env
|
||||
```
|
||||
|
||||
2. Activate the virtual environment.
|
||||
|
||||
```sh
|
||||
source ./envs/virtual-env/bin/activate
|
||||
```
|
||||
|
||||
3. Install the following dependencies:
|
||||
|
||||
- `pyarrow`
|
||||
- `flightsql-dbapi`
|
||||
- `pyinflux3`
|
||||
|
||||
```python
|
||||
pip install pyarrow flightsql-dbapi pyinflux3
|
||||
```
|
||||
|
||||
4. Build your python script to write the [sample line protocol](#home-sensor-data-line-protocol)
|
||||
to InfluxDB. _Save the script to a file and run `python SCRIPT_NAME` or run `python` to write and execute the script using the interactive shell._
|
||||
|
||||
1. Import the `InfluxDBClient3` object from the `influxdb_client_3` module.
|
||||
2. Use the `InfluxDBClient3` constructor to instantiate an InfluxDB Client.
|
||||
The example below assigns it to the `client` variable.
|
||||
Provide the following credentials:
|
||||
|
||||
- **host**: InfluxDB Cloud Serverless region hostname (URL without protocol or trailing slash)
|
||||
- **org**: InfluxDB Cloud Serverless organization ID
|
||||
- **token**: InfluxDB API token with write access to the target database
|
||||
- **database**: InfluxDB Cloud Serverless bucket name
|
||||
|
||||
3. Use the `client.write` method to write the line protocol to the **get-started**
|
||||
bucket. Provide the following:
|
||||
|
||||
- **Line protocol** as an array of strings where each element is an individual
|
||||
line of line protocol.
|
||||
- **`write_precision` option** to specify the timestamp precision as
|
||||
seconds (`s`).
|
||||
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
|
||||
```py
|
||||
from influxdb_client_3 import InfluxDBClient3
|
||||
|
||||
client = InfluxDBClient3(
|
||||
host="cloud2.influxdata.com",
|
||||
org="INFLUX_ORG_ID",
|
||||
token="INFLUX_API_WRITE_TOKEN",
|
||||
database="get-started"
|
||||
)
|
||||
|
||||
client.write([
|
||||
"home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000",
|
||||
"home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000",
|
||||
"home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600",
|
||||
"home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600",
|
||||
"home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200",
|
||||
"home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200",
|
||||
"home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800",
|
||||
"home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800",
|
||||
"home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400",
|
||||
"home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400",
|
||||
"home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000",
|
||||
"home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000",
|
||||
"home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600",
|
||||
"home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600",
|
||||
"home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200",
|
||||
"home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200",
|
||||
"home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800",
|
||||
"home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800",
|
||||
"home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400",
|
||||
"home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400",
|
||||
"home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000",
|
||||
"home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000",
|
||||
"home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600",
|
||||
"home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600",
|
||||
"home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200",
|
||||
"home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200"],
|
||||
write_precision='s'
|
||||
)
|
||||
```
|
||||
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
|
||||
<!----------------------------- END PYTHON CONTENT ---------------------------->
|
||||
{{% /tab-content %}}
|
||||
{{% tab-content %}}
|
||||
<!----------------------------- BEGIN GO CONTENT ------------------------------>
|
||||
|
||||
To write data to InfluxDB Cloud Serverless using Go, use the
|
||||
[influxdb-client-go module](https://github.com/influxdata/influxdb-client-go).
|
||||
|
||||
1. Create a new go module in your project directory.
|
||||
|
||||
1. Create a new module directory and navigate into it.
|
||||
2. Initialize a new Go module in the current working directory.
|
||||
3. Create a `write.go` file.
|
||||
|
||||
```sh
|
||||
mkdir influxdb_go_client && cd $_
|
||||
go mod init influxdb_go_client
|
||||
touch write.go
|
||||
```
|
||||
|
||||
2. Inside of `write.go` instantiate an InfluxDB write client to write the
|
||||
[line protocol above](#home-sensor-data-line-protocol) to InfluxDB.
|
||||
|
||||
1. Import the following packages
|
||||
|
||||
- `context`
|
||||
- `fmt`
|
||||
- `log`
|
||||
- `os`
|
||||
- `time`
|
||||
- `github.com/influxdata/influxdb-client-go/v2` aliased as `influxdb2`
|
||||
|
||||
2. Create a `dbWrite` function.
|
||||
3. In the `dbWrite` function, use `influxdb2.NewClientWithOptions` to
|
||||
create a `writeClient` that accepts write options.
|
||||
The write client requires the following credentials:
|
||||
|
||||
- **url**: InfluxDB Cloud Serverless region URL
|
||||
- **token**: [InfluxDB API token](/influxdb/cloud-serverless/admin/tokens/)
|
||||
with write access to the **get-started** bucket.
|
||||
_For security reasons, we recommend setting this as an environment
|
||||
variable rather than including the raw token string._
|
||||
|
||||
Because the timestamps in the line protocol are in second
|
||||
precision, **use `SetPrecision(time.Second)` to define the write precision option**.
|
||||
|
||||
4. Use `writeClient.WriteAPIBlocking` to define a `writeAPI`.
|
||||
The write API requires the following credentials:
|
||||
|
||||
- **bucket**: InfluxDB bucket name.
|
||||
|
||||
5. Define an array of line protocol strings where each element is a single
|
||||
line of line protocol.
|
||||
|
||||
6. Iterate through the array of line protocol and use `writeAPI.WriteRecord`
|
||||
to write each line of line protocol to InfluxDB.
|
||||
|
||||
7. Define a `main` function that executes the `dbWrite` function.
|
||||
|
||||
{{% influxdb/custom-timestamps %}}
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
||||
)
|
||||
|
||||
func dbWrite(ctx context.Context) error {
|
||||
// Create write client
|
||||
url := "https://cloud2.influxdata.com"
|
||||
// INFLUX_TOKEN is an environment variable you assigned to your API token value
|
||||
token := os.Getenv("INFLUX_TOKEN")
|
||||
writeClient := influxdb2.NewClientWithOptions(url, token, influxdb2.DefaultOptions().SetPrecision(time.Second))
|
||||
|
||||
// Define write API
|
||||
org := "ignored"
|
||||
bucket := "get-started"
|
||||
writeAPI := writeClient.WriteAPIBlocking(org, bucket)
|
||||
|
||||
line := [...]string{
|
||||
`home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000`,
|
||||
`home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000`,
|
||||
`home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600`,
|
||||
`home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600`,
|
||||
`home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200`,
|
||||
`home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800`,
|
||||
`home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800`,
|
||||
`home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400`,
|
||||
`home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400`,
|
||||
`home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000`,
|
||||
`home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000`,
|
||||
`home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600`,
|
||||
`home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600`,
|
||||
`home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200`,
|
||||
`home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800`,
|
||||
`home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800`,
|
||||
`home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400`,
|
||||
`home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000`,
|
||||
`home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000`,
|
||||
`home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600`,
|
||||
`home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600`,
|
||||
`home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200`,
|
||||
`home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200`,
|
||||
}
|
||||
|
||||
for _, lp := range line {
|
||||
err := writeAPI.WriteRecord(context.Background(), lp)
|
||||
if err != nil {
|
||||
log.Fatalf("Error writing line protocol: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Data has been written successfully.")
|
||||
writeClient.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := dbWrite(context.Background()); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Run the following command to install the necessary packages:
|
||||
|
||||
```sh
|
||||
go get ./...
|
||||
```
|
||||
|
||||
Run `write.go` to write the line protocol to your InfluxDB Cloud Serverless bucket:
|
||||
|
||||
```sh
|
||||
go run ./write.go
|
||||
```
|
||||
|
||||
{{% /influxdb/custom-timestamps %}}
|
||||
|
||||
<!------------------------------- END GO CONTENT ------------------------------>
|
||||
{{% /tab-content %}}
|
||||
|
||||
{{< /tabs-wrapper >}}
|
||||
|
||||
{{< expand-wrapper >}}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ list_code_example: |
|
|||
|
||||
client = FlightSQLClient(host='cloud2.influxdata.com',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'bucket-name': 'BUCKET_NAME'},
|
||||
metadata={'database': 'BUCKET_NAME'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
info = client.execute("SELECT * FROM home")
|
||||
|
|
@ -204,7 +204,7 @@ and the _DB API 2_ interface to instantiate a Flight SQL client configured for a
|
|||
# Instantiate a FlightSQLClient configured for your bucket
|
||||
client = FlightSQLClient(host='cloud2.influxdata.com',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'bucket-name': 'BUCKET_NAME'},
|
||||
metadata={'database': 'BUCKET_NAME'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
```
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ from flightsql import FlightSQLClient
|
|||
|
||||
client = FlightSQLClient(host='cloud2.influxdata.com',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'bucket-name': 'BUCKET_NAME'},
|
||||
metadata={'database': 'BUCKET_NAME'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
# Execute the query
|
||||
|
|
@ -273,7 +273,7 @@ from flightsql import FlightSQLClient
|
|||
# Instantiate a FlightSQLClient configured for a bucket
|
||||
client = FlightSQLClient(host='cloud2.influxdata.com',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'bucket-name': 'BUCKET_NAME'},
|
||||
metadata={'database': 'BUCKET_NAME'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
# Execute the query to retrieve FlightInfo
|
||||
|
|
|
|||
|
|
@ -214,17 +214,17 @@ With Superset running, you're ready to [log in](#log-in-to-superset) and set up
|
|||
|
||||
**Query parameters**
|
||||
|
||||
- **`?bucket-name`**: URL-encoded InfluxDB [bucket name](influxdb/cloud-serverless/admin/buckets/view-buckets/)
|
||||
- **`?database`**: URL-encoded InfluxDB [bucket name](influxdb/cloud-serverless/admin/buckets/view-buckets/)
|
||||
- **`?token`**: InfluxDB [API token](/influxdb/cloud-serverless/get-started/setup/) with `READ` access to the specified bucket
|
||||
|
||||
{{< code-callout "<(domain|port|bucket-name|token)>" >}}
|
||||
{{< code-callout "<(domain|port|database|token)>" >}}
|
||||
{{< code-callout "us-east-1-1\.aws\.cloud2\.influxdata\.com|443|example-bucket|example-token" >}}
|
||||
```sh
|
||||
# Syntax
|
||||
datafusion+flightsql://<domain>:<port>?bucket-name=<bucket-name>&token=<token>
|
||||
datafusion+flightsql://<domain>:<port>?database=<database>&token=<token>
|
||||
|
||||
# Example
|
||||
datafusion+flightsql://us-east-1-1.aws.cloud2.influxdata.com:443?bucket-name=example-bucket&token=example-token
|
||||
datafusion+flightsql://us-east-1-1.aws.cloud2.influxdata.com:443?database=example-bucket&token=example-token
|
||||
```
|
||||
{{< /code-callout >}}
|
||||
{{< /code-callout >}}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ to query InfluxDB with the Flight SQL protocol.
|
|||
|
||||
- [Install Grafana or login to Grafana Cloud](#install-grafana-or-login-to-grafana-cloud)
|
||||
- [Install the FlightSQL plugin](#install-the-flightsql-plugin)
|
||||
- [Use grafana-cli](#use-grafana-cli)
|
||||
- [Use the Grafana UI](#use-the-grafana-ui)
|
||||
- [Create and configure a FlightSQL datasource](#create-and-configure-a-flightsql-datasource)
|
||||
- [Query InfluxDB with Grafana](#query-influxdb-with-grafana)
|
||||
- [Build visualizations with Grafana](#build-visualizations-with-grafana)
|
||||
|
|
@ -118,12 +120,10 @@ Grafana Cloud instance.
|
|||
- **Require TLS/SSL**: Enable this toggle.
|
||||
|
||||
6. Add connection **MetaData**.
|
||||
Provide optional key-value pairs to send to your Flight SQL client.
|
||||
|
||||
InfluxDB Cloud Serverless requires your **bucket name** or **bucket-id**:
|
||||
InfluxDB Cloud Serverless requires _one_ of the following key-value pairs:
|
||||
|
||||
- **Key**: `bucket-name` or `bucket-id`
|
||||
- **Value**: Bucket name or bucket ID
|
||||
- **Key**: `database`, **Value**: Bucket name
|
||||
- **Key**: `bucket-id`, **Value**: Bucket ID
|
||||
|
||||
7. Click **Save & test**.
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ The following steps use Python, `flightsql-dbapi`, and `pyarrow` to query Influx
|
|||
|
||||
client = FlightSQLClient(host='cloud2.influxdata.com',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'bucket-name': 'INFLUX_BUCKET'},
|
||||
metadata={'database': 'INFLUX_BUCKET'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
info = client.execute("SELECT * FROM home")
|
||||
|
|
@ -127,7 +127,7 @@ import pandas
|
|||
|
||||
client = FlightSQLClient(host='cloud2.influxdata.com',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'bucket-name': 'INFLUX_BUCKET'},
|
||||
metadata={'database': 'INFLUX_BUCKET'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
info = client.execute("SELECT * FROM home")
|
||||
|
|
@ -155,7 +155,7 @@ import pandas
|
|||
|
||||
client = FlightSQLClient(host='cloud2.influxdata.com',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'bucket-name': 'INFLUX_BUCKET'},
|
||||
metadata={'database': 'INFLUX_BUCKET'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
info = client.execute("SELECT * FROM home")
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ The following example shows how to use Python with `flightsql-dbapi` and `pyarro
|
|||
# Instantiate a FlightSQLClient configured for a bucket
|
||||
client = FlightSQLClient(host='cloud2.influxdata.com',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'bucket-name': 'BUCKET_NAME'},
|
||||
metadata={'database': 'BUCKET_NAME'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
# Execute the query to retrieve FlightInfo
|
||||
|
|
@ -108,7 +108,7 @@ from flightsql import FlightSQLClient
|
|||
|
||||
client = FlightSQLClient(host='cloud2.influxdata.com',
|
||||
token='INFLUX_READ_WRITE_TOKEN',
|
||||
metadata={'bucket-name': 'BUCKET_NAME'},
|
||||
metadata={'database': 'BUCKET_NAME'},
|
||||
features={'metadata-reflection': 'true'})
|
||||
|
||||
info = client.execute('SELECT * FROM home')
|
||||
|
|
|
|||
|
|
@ -235,15 +235,28 @@ For information about installing the `influx` CLI, see
|
|||
with the following commands:
|
||||
|
||||
```sh
|
||||
# Ubuntu/Debian
|
||||
wget https://dl.influxdata.com/influxdb/releases/influxdb2-{{< latest-patch >}}-xxx.deb
|
||||
sudo dpkg -i influxdb2-{{< latest-patch >}}-xxx.deb
|
||||
|
||||
# Red Hat/CentOS/Fedora
|
||||
wget https://dl.influxdata.com/influxdb/releases/influxdb2-{{< latest-patch >}}-xxx.rpm
|
||||
sudo yum localinstall influxdb2-{{< latest-patch >}}-xxx.rpm
|
||||
# Ubuntu/Debian AMD64
|
||||
wget https://dl.influxdata.com/influxdb/releases/influxdb2-{{< latest-patch >}}-amd64.deb
|
||||
sudo dpkg -i influxdb2-{{< latest-patch >}}-amd64.deb
|
||||
```
|
||||
|
||||
```sh
|
||||
# Ubuntu/Debian ARM64
|
||||
wget https://dl.influxdata.com/influxdb/releases/influxdb2-{{< latest-patch >}}-arm64.deb
|
||||
sudo dpkg -i influxdb2-{{< latest-patch >}}-arm64.deb
|
||||
```
|
||||
|
||||
```sh
|
||||
# Red Hat/CentOS/Fedora x86-64 (x64, AMD64)
|
||||
wget https://dl.influxdata.com/influxdb/releases/influxdb2-{{< latest-patch >}}.x86_64.rpm
|
||||
sudo yum localinstall influxdb2-{{< latest-patch >}}.x86_64.rpm
|
||||
```
|
||||
|
||||
```sh
|
||||
# Red Hat/CentOS/Fedora AArch64 (ARMv8-A)
|
||||
wget https://dl.influxdata.com/influxdb/releases/influxdb2-{{< latest-patch >}}.aarch64.rpm
|
||||
sudo yum localinstall influxdb2-{{< latest-patch >}}.aarch64.rpm
|
||||
```
|
||||
_Use the exact filename of the download of `.rpm` package (for example, `influxdb2-{{< latest-patch >}}-amd64.rpm`)._
|
||||
|
||||
2. Start the InfluxDB service:
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ Rows that evaluate to `true` persist in the output data.
|
|||
(r) => (r._measurement == "cpu")
|
||||
|
||||
// Example with multiple filters
|
||||
(r) => r._measurement == "cpu" and r._field != "usage_system")
|
||||
(r) => (r._measurement == "cpu" and r._field != "usage_system")
|
||||
```
|
||||
|
||||
#### Use the following:
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ moving_average:
|
|||
code: |
|
||||
```js
|
||||
data
|
||||
|> movingAverage(n: 5)
|
||||
|> movingAverage(n: 3)
|
||||
```
|
||||
input: |
|
||||
| _time | _value |
|
||||
|
|
|
|||
Loading…
Reference in New Issue