fix: cloud 1.x compat docs link to oss 2.0 pages. Dedupe content. Use… (#3511)

* fix: cloud 1.x compat docs link to oss 2.0 pages. Dedupe content. Use consistent placeholders and placeholder instructions. Remove redundant shortcode. (closes #3477)

* fix: placeholders in 2.0 1.x query.

* fix: cloud example user email address (#3477).

* Update content/influxdb/v2.1/reference/api/influxdb-1x/_index.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
pull/3488/head
Jason Stirnaman 2021-12-21 09:16:41 -06:00 committed by GitHub
parent ffeccc5224
commit df14f93735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 291 additions and 477 deletions

View File

@ -14,153 +14,4 @@ related:
- /influxdb/cloud/query-data/influxql
---
The InfluxDB v2 API includes InfluxDB 1.x compatibility `/write` and `/query`
endpoints that work with InfluxDB 1.x client libraries and third-party integrations
like [Grafana](https://grafana.com) and others.
<a class="btn" href="/influxdb/cloud/api/v1-compatibility/">View full v1 compatibility API documentation</a>
## Authentication
{{% cloud %}}
InfluxDB Cloud requires all query and write requests to be authenticated using
[InfluxDB API tokens](/influxdb/cloud/security/tokens/).
{{% /cloud %}}
Use InfluxDB API tokens with the following authentication schemes:
* [Authenticate with the Token scheme](#authenticate-with-the-token-scheme)
* [Authenticate with a username and password scheme](#authenticate-with-a-username-and-password-scheme)
### Authenticate with the Token scheme
Token authentication requires the following credential:
- **token**: InfluxDB [API token](/influxdb/cloud/security/tokens/)
Use the `Authorization` header with the `Token` scheme to provide your
token to InfluxDB.
##### Syntax
```sh
Authorization: Token INFLUXDB_API_TOKEN
```
##### Example
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[curl](#curl)
[Node.js](#nodejs)
{{% /code-tabs %}}
{{% code-tab-content %}}
```sh
{{% get-shared-text "api/v1-compat/auth/oss/token-auth.sh" %}}
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```js
{{% get-shared-text "api/v1-compat/auth/oss/token-auth.js" %}}
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
### Authenticate with a username and password scheme
Use the following schemes with clients that support the InfluxDB 1.x convention of username and password (that don't support the `Authorization: Token` scheme):
- [Basic authentication](#basic-authentication)
- [Query string authentication](#query-string-authentication)
##### Manage credentials
Username and password schemes require the following credentials:
- **username**: InfluxDB Cloud username
(Use the email address you signed up with as your username, _e.g._ `exampleuser@influxdata.com`.)
- **password**: InfluxDB Cloud [API token](/influxdb/cloud/security/tokens/)
#### Basic authentication
Use the `Authorization` header with the `Basic` scheme to provide username and password credentials to InfluxDB.
{{% api/v1-compat/basic-auth-syntax %}}
##### Syntax
```sh
Authorization: Basic INFLUX_USERNAME:INFLUX_API_TOKEN
```
##### Example
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[curl](#curl)
[Node.js](#nodejs)
{{% /code-tabs %}}
{{% code-tab-content %}}
```sh
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.sh" %}}
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```js
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.js" %}}
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
Replace the following:
- *`exampleuser@influxdata.com`*: the email address that you signed up with
- *`INFLUX_API_TOKEN`*: your [InfluxDB API token](/influxdb/cloud/reference/glossary/#token)
#### Query string authentication
Use InfluxDB 1.x API parameters to provide username and password credentials through the query string.
{{% note %}}
##### Consider when using query string parameters
- URL-encode query parameters that may contain whitespace or other special characters.
- Be aware of the [risks](https://owasp.org/www-community/vulnerabilities/Information_exposure_through_query_strings_in_url) when exposing sensitive data through URLs.
{{% /note %}}
##### Syntax
```sh
/query/?u=INFLUX_USERNAME&p=INFLUX_API_TOKEN
/write/?u=INFLUX_USERNAME&p=INFLUX_API_TOKEN
```
##### Example
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[curl](#curl)
[Node.js](#nodejs)
{{% /code-tabs %}}
{{% code-tab-content %}}
```sh
{{% get-shared-text "api/v1-compat/auth/cloud/querystring-auth.sh" %}}
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```js
{{% get-shared-text "api/v1-compat/auth/cloud/querystring-auth.js" %}}
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
Replace the following:
- *`exampleuser@influxdata.com`*: the email address that you signed up with
- *`INFLUX_API_TOKEN`*: your [InfluxDB API token](/influxdb/cloud/reference/glossary/#token)
## InfluxQL support
The compatibility API supports InfluxQL, with the following caveats:
- The `INTO` clause (e.g. `SELECT ... INTO ...`) is not supported.
- With the exception of [`DELETE`](/{{< latest "influxdb" "v1" >}}/query_language/manage-database/#delete-series-with-delete) and
[`DROP MEASUREMENT`](/{{< latest "influxdb" "v1" >}}/query_language/manage-database/#delete-measurements-with-drop-measurement) queries, which are still allowed,
InfluxQL database management commands are not supported.
## Compatibility endpoints
{{< children readmore=true >}}
{{% duplicate-oss %}}

View File

@ -14,47 +14,4 @@ related:
- /influxdb/cloud/api/#tag/DBRPs, InfluxDB v2 API /dbrps endpoint
---
The InfluxDB 1.x data model includes [databases](/influxdb/v1.8/concepts/glossary/#database)
and [retention policies](/influxdb/v1.8/concepts/glossary/#retention-policy-rp).
InfluxDB Cloud replaces both with [buckets](/influxdb/v2.0/reference/glossary/#bucket).
To support InfluxDB 1.x query and write patterns in InfluxDB Cloud, databases and retention
policies are mapped to buckets using the **database and retention policy (DBRP) mapping service**.
The DBRP mapping service uses the **database** and **retention policy** specified in
[1.x compatibility API](/influxdb/v2.0/reference/api/influxdb-1x/) requests to route operations to a bucket.
{{% note %}}
For more information, see [Map unmapped buckets](/influxdb/v2.0/query-data/influxql/#map-unmapped-buckets).
{{% /note %}}
### Default retention policies
A database can have multiple retention policies with one set as default.
If no retention policy is specified in a query or write request, InfluxDB uses
the default retention policy for the specified database.
### When writing data
When writing data using the
[`/write` compatibility endpoint](/influxdb/v2.0/reference/api/influxdb-1x/write/),
the DBRP mapping service checks for a bucket mapped to the database and retention policy:
- If a mapped bucket is found, data is written to the bucket.
- If an unmapped bucket with a name matching:
- **database/retention policy** exists, a DBRP mapping is added to the bucket,
and data is written to the bucket.
- **database** exists (without a specified retention policy), the default
database retention policy is used, a DBRP mapping is added to the bucket,
and data is written to the bucket.
### When querying data
When querying data from InfluxDB Cloud and InfluxDB OSS 2.0 using the
[`/query` compatibility endpoint](/influxdb/v2.0/reference/api/influxdb-1x/query/),
the DBRP mapping service checks for the specified database and retention policy
(if no retention policy is specified, the database's default retention policy is used):
- If a mapped bucket exists, data is queried from the mapped bucket.
- If no mapped bucket exists, InfluxDB returns an error. See how to [Map unmapped buckets](/influxdb/v2.0/query-data/influxql/#map-unmapped-buckets).
_For more information on the DBRP mapping API, see the [`/api/v2/dbrps` endpoint documentation](/influxdb/v2.0/api/#tag/DBRPs)._
{{% duplicate-oss %}}

View File

@ -18,121 +18,4 @@ related:
- /influxdb/cloud/query-data/influxql
---
The `/query` 1.x compatibility endpoint queries InfluxDB Cloud and InfluxDB OSS 2.0 using **InfluxQL**.
Use the `GET` request method to query data from the `/query` endpoint.
{{< api-endpoint method="get" endpoint="http://localhost:8086/query" >}}
The `/query` compatibility endpoint uses the **database** and **retention policy**
specified in the query request to map the request to an InfluxDB bucket.
For more information, see [Database and retention policy mapping](/{{% latest "influxdb" %}}/reference/api/influxdb-1x/dbrp).
{{% note %}}
If you have an existing bucket that doesn't follow the **database/retention-policy** naming convention,
you **must** [manually create a database and retention policy mapping](/influxdb/v2.0/query-data/influxql/#map-unmapped-buckets)
to query that bucket with the `/query` compatibility API.
{{% /note %}}
## Authentication
{{% api/v1-compat/cloud/authentication %}}
## Query string parameters
{{% api/url-encode-note %}}
### u
(Optional) The InfluxDB Cloud **username** to authenticate the request.
_See [query string authentication](/influxdb/cloud/reference/api/influxdb-1x/#query-string-authentication)._
### p
(Optional) The InfluxDB Cloud **API token** to authenticate the request.
_See [query string authentication](/influxdb/cloud/reference/api/influxdb-1x/#query-string-authentication)._
### db
({{< req >}}) The **database** to query data from.
This is mapped to an InfluxDB [bucket](/influxdb/v2.0/reference/glossary/#bucket).
_See [Database and retention policy mapping](/influxdb/v2.0/reference/api/influxdb-1x/dbrp/)._
### rp
The **retention policy** to query data from.
This is mapped to an InfluxDB [bucket](/influxdb/v2.0/reference/glossary/#bucket).
_See [Database and retention policy mapping](/influxdb/v2.0/reference/api/influxdb-1x/dbrp/)._
### q
({{< req >}}) The **InfluxQL** query to execute.
To execute multiple queries, delimit queries with a semicolon (`;`).
### epoch
Return results with [Unix timestamps](/influxdb/v2.0/reference/glossary/#unix-timestamp)
(also known as epoch timestamps) in the specified precision instead of
[RFC3339 timestamps](/influxdb/v2.0/reference/glossary/#rfc3339-timestamp) with nanosecond precision.
The following precisions are available:
- `ns` - nanoseconds
- `u` or `µ` - microseconds
- `ms` - milliseconds
- `s` - seconds
- `m` - minutes
- `h` - hours
## Query examples
- [Query using basic authentication](#query-using-basic-authentication)
- [Query a non-default retention policy](#query-a-non-default-retention-policy)
- [Execute multiple queries](#execute-multiple-queries)
- [Return query results with millisecond Unix timestamps](#return-query-results-with-millisecond-unix-timestamps)
- [Execute InfluxQL queries from a file](#execute-influxql-queries-from-a-file)
##### Query using basic authentication
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[curl](#curl)
[Node.js](#nodejs)
{{% /code-tabs %}}
{{% code-tab-content %}}
```sh
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.sh" %}}
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```js
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.js" %}}
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
##### Query a non-default retention policy
```sh
curl --get http://localhost:8086/query \
--header "Authorization: Token YourAuthToken" \
--data-urlencode "db=mydb" \
--data-urlencode "rp=customrp" \
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
```
##### Execute multiple queries
```sh
curl --get http://localhost:8086/query \
--header "Authorization: Token YourAuthToken" \
--data-urlencode "db=mydb" \
--data-urlencode "q=SELECT * FROM mem WHERE host=host1;SELECT mean(used_percent) FROM mem WHERE host=host1 GROUP BY time(10m)"
```
##### Return query results with millisecond Unix timestamps
```sh
curl --get http://localhost:8086/query \
--header "Authorization: Token YourAuthToken" \
--data-urlencode "db=mydb" \
--data-urlencode "rp=myrp" \
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1" \
--data-urlencode "epoch=ms"
```
##### Execute InfluxQL queries from a file
```sh
curl --get http://localhost:8086/query \
--header "Authorization: Token YourAuthToken" \
--data-urlencode "db=mydb" \
--form "q=@path/to/influxql.txt" \
--form "async=true"
```
{{% duplicate-oss %}}

View File

@ -19,109 +19,4 @@ related:
- /influxdb/cloud/reference/syntax/line-protocol
---
The `/write` 1.x compatibility endpoint writes data to InfluxDB Cloud and InfluxDB OSS 2.0
using patterns from the InfluxDB 1.x `/write` API endpoint.
Use the `POST` request method to write [line protocol](/influxdb/cloud/reference/syntax/line-protocol/)
to the `/write` endpoint.
{{< api-endpoint method="post" endpoint="https://cloud2.influxdata.com/write" >}}
{{% note %}}
If you have an existing bucket that doesn't follow the **database/retention-policy** naming convention,
you **must** [manually create a database and retention policy mapping](/influxdb/cloud/query-data/influxql/#map-unmapped-buckets)
to write data to that bucket with the `/write` compatibility API.
{{% /note %}}
## Authentication
{{% api/v1-compat/cloud/authentication %}}
## Request body
Include your line protocol in the request body.
**Binary encode** the line protocol to prevent unintended formatting.
The examples [below](#write-examples) use the curl `--data-binary` flag to binary
encode the line protocol.
## Query string parameters
### u
(Optional) The InfluxDB Cloud **username** to authenticate the request.
_See [query string authentication](/influxdb/cloud/reference/api/influxdb-1x/#query-string-authentication)._
### p
(Optional) The InfluxDB Cloud **API token** to authenticate the request.
_See [query string authentication](/influxdb/cloud/reference/api/influxdb-1x/#query-string-authentication)._
### db
({{< req >}}) The **database** to write data to.
This is mapped to an InfluxDB [bucket](/influxdb/cloud/reference/glossary/#bucket).
_See [Database and retention policy mapping](/influxdb/cloud/reference/api/influxdb-1x/dbrp/)._
### rp
The **retention policy** to write data to.
This is mapped to an InfluxDB [bucket](/influxdb/cloud/reference/glossary/#bucket).
_See [Database and retention policy mapping](/influxdb/cloud/reference/api/influxdb-1x/dbrp/)._
### precision
The precision of [Unix timestamps](/influxdb/cloud/reference/glossary/#unix-timestamp) in the line protocol.
Default is nanosconds (`ns`).
The following precisions are available:
- `ns` - nanoseconds
- `u` or `µ` - microseconds
- `ms` - milliseconds
- `s` - seconds
- `m` - minutes
- `h` - hours
## Write examples
- [Write data using basic authentication](#write-data-using-basic-authentication)
- [Write data to a non-default retention policy](#write-data-to-a-non-default-retention-policy)
- [Write multiple lines of line protocol](#write-multiple-lines-of-line-protocol)
- [Write data with millisecond Unix timestamps](#write-data-with-millisecond-unix-timestamps)
- [Use curl to write data from a file](#use-curl-to-write-data-from-a-file)
##### Write data using basic authentication
```sh
curl --request POST https://cloud2.influxdata.com/write?db=mydb \
--user "myusername:YourAuthToken" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
```
##### Write data using token authentication
```sh
curl --request POST https://cloud2.influxdata.com/write?db=mydb \
--header "Authorization: Token YourAuthToken" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
```
##### Write data to a non-default retention policy
```sh
curl --request POST https://cloud2.influxdata.com/write?db=mydb&rp=customrp \
--user "myusername:YourAuthToken" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
```
##### Write multiple lines of line protocol
```sh
curl --request POST https://cloud2.influxdata.com/write?db=mydb \
--header "Authorization: Token YourAuthToken" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000
measurement,host=host2 field1=14i,field2=12.7 1577836800000000000
measurement,host=host3 field1=5i,field2=6.8 1577836800000000000"
```
##### Write data with millisecond Unix timestamps
```sh
curl --request POST https://cloud2.influxdata.com/write?db=mydb&precision=ms \
--header "Authorization: Token YourAuthToken" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000"
```
##### Use curl to write data from a file
```sh
curl --request POST https://cloud2.influxdata.com/write?db=mydb \
--header "Authorization: Token YourAuthToken" \
--data-binary @path/to/line-protocol.txt
```
{{% duplicate-oss %}}

View File

@ -74,7 +74,8 @@ Username and password schemes require the following credentials:
{{% note %}}
#### Password or Token
{{% api/v1-compat/oss/password-or-token %}}
If you have [set a password](/influxdb/v2.0/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations) for the 1.x-compatible username, provide the 1.x-compatible password.
If you haven't set a password for the 1.x-compatible username, provide the InfluxDB [authentication token](/influxdb/v2.0/security/tokens/) as the password.
{{% /note %}}
For information about creating and managing 1.x-compatible authorizations, see:

View File

@ -109,7 +109,7 @@ The following precisions are available:
##### Query a non-default retention policy
```sh
curl --get http://localhost:8086/query \
--user "OneDotXUsername":"myPasswordOrAuthToken" \
--user "INFLUX_USERNAME":"INFLUX_PASSWORD_OR_TOKEN" \
--data-urlencode "db=mydb" \
--data-urlencode "rp=customrp" \
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
@ -118,7 +118,7 @@ curl --get http://localhost:8086/query \
##### Execute multiple queries
```sh
curl --get http://localhost:8086/query \
--header "Authorization: Token YourAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-urlencode "db=mydb" \
--data-urlencode "q=SELECT * FROM mem WHERE host=host1;SELECT mean(used_percent) FROM mem WHERE host=host1 GROUP BY time(10m)"
```
@ -126,7 +126,7 @@ curl --get http://localhost:8086/query \
##### Return query results with millisecond Unix timestamps
```sh
curl --get http://localhost:8086/query \
--header "Authorization: Token YourAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-urlencode "db=mydb" \
--data-urlencode "rp=myrp" \
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1" \
@ -136,7 +136,7 @@ curl --get http://localhost:8086/query \
##### Execute InfluxQL queries from a file
```sh
curl --get http://localhost:8086/query \
--header "Authorization: Token YourAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-urlencode "db=mydb" \
--form "q=@path/to/influxql.txt" \
--form "async=true"

View File

@ -20,12 +20,13 @@ InfluxDB 1.x client libraries and third-party integrations like [Grafana](https:
<a class="btn" href="/influxdb/v2.1/api/v1-compatibility/">View full v1 compatibility API documentation</a>
## Authentication
InfluxDB {{< current-version >}} requires all query and write requests to be authenticated with an
[API token](/influxdb/v2.1/security/tokens/) or 1.x compatible
InfluxDB 1.x compatibility endpoints require all query and write requests to be authenticated with an
[API token](/influxdb/v2.1/security/tokens/) or 1.x-compatible
credentials.
* [Authenticate with the Token scheme](#authenticate-with-the-token-scheme)
* [Authenticate with a username and password scheme](#authenticate-with-a-username-and-password-scheme)
* [Authenticate with a 1.x username and password scheme](#authenticate-with-a-username-and-password-scheme)
### Authenticate with the Token scheme
Token authentication requires the following credential:
@ -37,7 +38,7 @@ Use the `Authorization` header with the `Token` scheme to provide your token to
#### Syntax
```sh
Authorization: Token <token>
Authorization: Token INFLUX_API_TOKEN
```
#### Example
@ -66,7 +67,9 @@ Use the following authentication schemes with clients that support the InfluxDB
- [Basic authentication](#basic-authentication)
- [Query string authentication](#query-string-authentication)
##### Manage credentials
#### Manage credentials
{{% oss-only %}}
Username and password schemes require the following credentials:
- **username**: 1.x username (this is separate from the UI login username)
@ -74,7 +77,8 @@ Username and password schemes require the following credentials:
{{% note %}}
#### Password or Token
{{% api/v1-compat/oss/password-or-token %}}
If you have [set a password](/influxdb/v2.1/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations) for the 1.x-compatible username, provide the 1.x-compatible password.
If you haven't set a password for the 1.x-compatible username, provide the InfluxDB [authentication token](/influxdb/v2.1/security/tokens/) as the password.
{{% /note %}}
For information about creating and managing 1.x-compatible authorizations, see:
@ -82,6 +86,16 @@ For information about creating and managing 1.x-compatible authorizations, see:
- [`influx v1 auth` command](/influxdb/v2.1/reference/cli/influx/v1/auth/)
- [Manually upgrade 1.x-compatible authorizations](/influxdb/v2.1/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations)
{{% /oss-only %}}
{{% cloud-only %}}
- **username**: InfluxDB Cloud username
(Use the email address you signed up with as your username, _e.g._ `exampleuser@influxdata.com`.)
- **password**: InfluxDB Cloud [API token](/influxdb/cloud/security/tokens/)
{{% /cloud-only %}}
#### Basic authentication
Use the `Authorization` header with the `Basic` scheme to provide username and
@ -90,12 +104,28 @@ password credentials to InfluxDB.
{{% api/v1-compat/basic-auth-syntax %}}
##### Syntax
{{% oss-only %}}
```sh
Authorization: Basic <username>:<password>
Authorization: Basic INFLUX_USERNAME:INFLUX_PASSWORD_OR_TOKEN
```
{{% /oss-only %}}
{{% cloud-only %}}
```sh
Authorization: Basic exampleuser@influxdata.com:INFLUX_API_TOKEN
```
{{% /cloud-only %}}
##### Example
{{% oss-only %}}
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[curl](#curl)
@ -113,6 +143,35 @@ Authorization: Basic <username>:<password>
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
{{% /oss-only %}}
{{% cloud-only %}}
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[curl](#curl)
[Node.js](#nodejs)
{{% /code-tabs %}}
{{% code-tab-content %}}
```sh
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.sh" %}}
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```js
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.js" %}}
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
Replace the following:
- *`exampleuser@influxdata.com`*: the email address that you signed up with
- *`INFLUX_API_TOKEN`*: your [InfluxDB API token](/influxdb/cloud/reference/glossary/#token)
{{% /cloud-only %}}
#### Query string authentication
Use InfluxDB 1.x API parameters to provide credentials through the query string.
@ -125,13 +184,27 @@ Use InfluxDB 1.x API parameters to provide credentials through the query string.
##### Syntax
{{% oss-only %}}
```sh
/query/?u=<username>&p=<password>
/write/?u=<username>&p=<password>
/query/?u=INFLUX_USERNAME&p=INFLUX_PASSWORD_OR_TOKEN
/write/?u=INFLUX_USERNAME&p=INFLUX_PASSWORD_OR_TOKEN
```
{{% /oss-only %}}
{{% cloud-only %}}
```sh
/query/?u=INFLUX_USERNAME&p=INFLUX_API_TOKEN
/write/?u=INFLUX_USERNAME&p=INFLUX_API_TOKEN
```
{{% /cloud-only %}}
##### Example
{{% oss-only %}}
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[curl](#curl)
@ -149,6 +222,38 @@ Use InfluxDB 1.x API parameters to provide credentials through the query string.
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
Replace the following:
- *`INFLUX_USERNAME`*: [InfluxDB 1.x username](#manage-credentials)
- *`INFLUX_PASSWORD_OR_TOKEN`*: [InfluxDB 1.x password or InfluxDB API token](#manage-credentials)
{{% /oss-only %}}
{{% cloud-only %}}
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[curl](#curl)
[Node.js](#nodejs)
{{% /code-tabs %}}
{{% code-tab-content %}}
```sh
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.sh" %}}
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```js
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.js" %}}
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
Replace the following:
- *`exampleuser@influxdata.com`*: the email address that you signed up with
- *`INFLUX_API_TOKEN`*: your [InfluxDB API token](/influxdb/cloud/reference/glossary/#token)
{{% /cloud-only %}}
##### InfluxQL support
The compatibility API supports InfluxQL, with the following caveats:

View File

@ -16,8 +16,8 @@ related:
The InfluxDB 1.x data model includes [databases](/influxdb/v1.8/concepts/glossary/#database)
and [retention policies](/influxdb/v1.8/concepts/glossary/#retention-policy-rp).
InfluxDB OSS {{< current-version >}} replaces both with [buckets](/influxdb/v2.1/reference/glossary/#bucket).
To support InfluxDB 1.x query and write patterns in InfluxDB OSS {{< current-version >}}, databases and retention
InfluxDB Cloud and InfluxDB OSS {{< current-version >}} replace databases and retention policies with [buckets](/influxdb/v2.1/reference/glossary/#bucket).
To support InfluxDB 1.x query and write patterns in InfluxDB OSS {{< current-version >}} and Cloud, databases and retention
policies are mapped to buckets using the **database and retention policy (DBRP) mapping service**.
The DBRP mapping service uses the **database** and **retention policy** specified in
@ -41,10 +41,26 @@ When writing data using the
[`/write` compatibility endpoint](/influxdb/v2.1/reference/api/influxdb-1x/write/),
the DBRP mapping service checks for a bucket mapped to the database and retention policy:
{{% oss-only %}}
- If a mapped bucket is found, data is written to the bucket.
- If an unmapped bucket, InfluxDB returns an error.
- If the bucket is unmapped, InfluxDB returns an error.
See how to [Map unmapped buckets](/influxdb/v2.1/query-data/influxql/#map-unmapped-buckets).
{{% /oss-only %}}
{{% cloud-only %}}
- If a mapped bucket is found, data is written to the bucket.
- If an unmapped bucket with a name matching:
- **database/retention policy** exists, a DBRP mapping is added to the bucket,
and data is written to the bucket.
- **database** exists (without a specified retention policy), the default
database retention policy is used, a DBRP mapping is added to the bucket,
and data is written to the bucket.
{{% /cloud-only %}}
### When querying data
When querying data from InfluxDB Cloud and InfluxDB OSS {{< current-version >}} using the

View File

@ -89,6 +89,9 @@ The following precisions are available:
- [Execute InfluxQL queries from a file](#execute-influxql-queries-from-a-file)
##### Query using basic authentication
{{% oss-only %}}
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[curl](#curl)
@ -106,10 +109,34 @@ The following precisions are available:
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
{{% /oss-only %}}
{{% cloud-only %}}
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[curl](#curl)
[Node.js](#nodejs)
{{% /code-tabs %}}
{{% code-tab-content %}}
```sh
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.sh" %}}
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```js
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.js" %}}
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
{{% /cloud-only %}}
##### Query a non-default retention policy
```sh
curl --get http://localhost:8086/query \
--user "OneDotXUsername":"myPasswordOrAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-urlencode "db=mydb" \
--data-urlencode "rp=customrp" \
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
@ -118,7 +145,7 @@ curl --get http://localhost:8086/query \
##### Execute multiple queries
```sh
curl --get http://localhost:8086/query \
--header "Authorization: Token YourAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-urlencode "db=mydb" \
--data-urlencode "q=SELECT * FROM mem WHERE host=host1;SELECT mean(used_percent) FROM mem WHERE host=host1 GROUP BY time(10m)"
```
@ -126,7 +153,7 @@ curl --get http://localhost:8086/query \
##### Return query results with millisecond Unix timestamps
```sh
curl --get http://localhost:8086/query \
--header "Authorization: Token YourAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-urlencode "db=mydb" \
--data-urlencode "rp=myrp" \
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1" \
@ -136,8 +163,11 @@ curl --get http://localhost:8086/query \
##### Execute InfluxQL queries from a file
```sh
curl --get http://localhost:8086/query \
--header "Authorization: Token YourAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-urlencode "db=mydb" \
--form "q=@path/to/influxql.txt" \
--form "async=true"
```
Replace the following:
- *`INFLUX_API_TOKEN`*: InfluxDB API token

View File

@ -35,6 +35,8 @@ to write data to that bucket with the `/write` compatibility API.
## Authentication
{{% oss-only %}}
Use one of the following authentication methods:
* **token authentication**
* **basic authentication with username and password**
@ -42,6 +44,14 @@ Use one of the following authentication methods:
_For more information, see [Authentication](/influxdb/v2.1/reference/api/influxdb-1x/#authentication)._
{{% /oss-only %}}
{{% cloud-only %}}
{{% api/v1-compat/cloud/authentication %}}
{{% /cloud-only %}}
## Request body
Include your line protocol in the request body.
**Binary encode** the line protocol to prevent unintended formatting.
@ -50,6 +60,8 @@ encode the line protocol.
## Query string parameters
{{% oss-only %}}
### u
(Optional) The 1.x **username** to authenticate the request.
_See [query string authentication](/influxdb/v2.1/reference/api/influxdb-1x/#query-string-authentication)._
@ -58,6 +70,20 @@ _See [query string authentication](/influxdb/v2.1/reference/api/influxdb-1x/#que
(Optional) The 1.x **password** to authenticate the request.
_See [query string authentication](/influxdb/v2.1/reference/api/influxdb-1x/#query-string-authentication)._
{{% /oss-only %}}
{{% cloud-only %}}
### u
(Optional) The InfluxDB Cloud **username** to authenticate the request.
_See [query string authentication](/influxdb/cloud/reference/api/influxdb-1x/#query-string-authentication)._
### p
(Optional) The InfluxDB Cloud **API token** to authenticate the request.
_See [query string authentication](/influxdb/cloud/reference/api/influxdb-1x/#query-string-authentication)._
{{% /cloud-only %}}
### db
({{< req >}}) The **database** to write data to.
This is mapped to an InfluxDB [bucket](/influxdb/v2.1/reference/glossary/#bucket).
@ -89,30 +115,48 @@ The following precisions are available:
- [Use curl to write data from a file](#use-curl-to-write-data-from-a-file)
##### Write data using basic authentication
{{% oss-only %}}
```sh
curl --request POST http://localhost:8086/write?db=mydb \
--user "myusername:PasswordOrAuthToken" \
--user "INFLUX_USERNAME:INFLUX_PASSWORD_OR_TOKEN" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
```
{{% /oss-only %}}
{{% cloud-only %}}
```sh
curl --request POST https://cloud2.influxdata.com/write?db=mydb \
--user "exampleuser@influxdata.com:INFLUX_API_TOKEN" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
```
{{% /cloud-only %}}
##### Write data using token authentication
```sh
curl --request POST http://localhost:8086/write?db=mydb \
--header "Authorization: Token YourAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
```
##### Write data to a non-default retention policy
```sh
curl --request POST http://localhost:8086/write?db=mydb&rp=customrp \
--user "myusername:PasswordOrAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
```
##### Write multiple lines of line protocol
```sh
curl --request POST http://localhost:8086/write?db=mydb \
--header "Authorization: Token YourAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000
measurement,host=host2 field1=14i,field2=12.7 1577836800000000000
measurement,host=host3 field1=5i,field2=6.8 1577836800000000000"
@ -121,13 +165,30 @@ measurement,host=host3 field1=5i,field2=6.8 1577836800000000000"
##### Write data with millisecond Unix timestamps
```sh
curl --request POST http://localhost:8086/write?db=mydb&precision=ms \
--header "Authorization: Token YourAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000"
```
##### Use curl to write data from a file
```sh
curl --request POST http://localhost:8086/write?db=mydb \
--header "Authorization: Token YourAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-binary @path/to/line-protocol.txt
```
{{% oss-only %}}
Replace the following:
- *`INFLUX_USERNAME`*: [InfluxDB 1.x username](/influxdb/v2.1/reference/api/influxdb-1x/#manage-credentials)
- *`INFLUX_PASSWORD_OR_TOKEN`*: [InfluxDB 1.x password or InfluxDB API token](/influxdb/v2.1/reference/api/influxdb-1x/#manage-credentials)
- *`INFLUX_API_TOKEN`*: your [InfluxDB API token](/influxdb/v2.1/reference/glossary/#token)
{{% /oss-only %}}
{{% cloud-only %}}
Replace the following:
- *`exampleuser@influxdata.com`*: the email address that you signed up with
- *`INFLUX_API_TOKEN`*: your [InfluxDB API token](/influxdb/cloud/reference/glossary/#token)
{{% /cloud-only %}}

View File

@ -1,2 +0,0 @@
If you have [set a password](/influxdb/v2.0/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations) for the 1.x-compatible username, provide the 1.x-compatible password.
If you haven't set a password for the 1.x-compatible username, provide the InfluxDB [authentication token](/influxdb/v2.0/security/tokens/) as the password.

View File

@ -1,8 +1,12 @@
/**
* Use an InfluxDB 1.x compatible username and password
* to query the InfluxDB 1.x compatibility API
*
* Use Basic authentication
* Use Basic authentication with an
* InfluxDB 1.x compatible username and password
* to query the InfluxDB 1.x compatibility API.
* Replace INFLUX_USERNAME with your 1.x-compatible username.
* Replace INFLUX_PASSWORD_OR_TOKEN with your InfluxDB API token
* or 1.x-compatible password.
* Use the default retention policy.
*/
const https = require('https');
@ -17,7 +21,7 @@ function queryWithUsername() {
const options = {
host: 'localhost:8086',
path: '/query?' + querystring.stringify(queryparams),
auth: 'OneDotXUsername:yourPasswordOrToken',
auth: 'INFLUX_USERNAME:INFLUX_PASSWORD_OR_TOKEN',
headers: {
'Content-type': 'application/json'
},

View File

@ -1,9 +1,13 @@
#######################################
# Use an InfluxDB 1.x compatible username
# and password with Basic Authentication
# to query the InfluxDB 1.x compatibility API
# Use Basic authentication with an
# InfluxDB 1.x compatible username and password
# to query the InfluxDB 1.x compatibility API.
#
# Replace INFLUX_USERNAME with your 1.x-compatible username.
# Replace INFLUX_PASSWORD_OR_TOKEN with your InfluxDB API token
# or 1.x-compatible password.
#######################################
# Use default retention policy
# Use the default retention policy.
#######################################
# Use the --user option with `--user <username>:<password>` syntax
# or the `--user <username>` interactive syntax to ensure your credentials are
@ -11,6 +15,6 @@
#######################################
curl --get "http://localhost:8086/query" \
--user "OneDotXUsername":"yourPasswordOrToken" \
--user "INFLUX_USERNAME":"INFLUX_PASSWORD_OR_TOKEN" \
--data-urlencode "db=mydb" \
--data-urlencode "q=SELECT * FROM cpu_usage"

View File

@ -1,11 +1,13 @@
/**
* Use an InfluxDB 1.x compatible username and password
* to query the InfluxDB 1.x compatibility API
* Use querystring authentication with an
* InfluxDB 1.x compatible username and password
* to query the InfluxDB 1.x compatibility API.
*
* Use authentication query parameters:
* ?u=<username>&p=<password>
* Replace INFLUX_USERNAME with your 1.x-compatible username.
* Replace INFLUX_PASSWORD_OR_TOKEN with your InfluxDB API token
* or 1.x-compatible password.
*
* Use default retention policy.
* Use the default retention policy.
*/
const https = require('https');
@ -15,8 +17,8 @@ function queryWithToken() {
const queryparams = {
db: 'mydb',
q: 'SELECT * FROM cpu_usage',
u: 'OneDotXUsername',
p: 'yourPasswordOrToken'
u: 'INFLUX_USERNAME',
p: 'INFLUX_PASSWORD_OR_TOKEN'
};
const options = {

View File

@ -1,14 +1,17 @@
#######################################
# Use an InfluxDB 1.x compatible username and password
# to query the InfluxDB 1.x compatibility API
#######################################
# Use authentication query parameters:
# ?u=<username>&p=<password>
# Use default retention policy.
# Use querystring authentication with an
# InfluxDB 1.x compatible username and password
# to query the InfluxDB 1.x compatibility API.
#
# Replace INFLUX_USERNAME with your 1.x-compatible username.
# Replace INFLUX_PASSWORD_OR_TOKEN with your InfluxDB API token
# or 1.x-compatible password.
#
# Use the default retention policy.
#######################################
curl --get "http://localhost:8086/query" \
--data-urlencode "u=OneDotXUsername" \
--data-urlencode "p=yourPasswordOrToken" \
--data-urlencode "u=INFLUX_USERNAME" \
--data-urlencode "p=INFLUX_PASSWORD_OR_TOKEN" \
--data-urlencode "db=mydb" \
--data-urlencode "q=SELECT * FROM cpu_usage"

View File

@ -1,6 +1,8 @@
/**
* Use a token in the Authorization header
* to query the InfluxDB 1.x compatibility API
* Use the Token authentication scheme
* to query the InfluxDB 1.x compatibility API.
*
* Replace INFLUX_API_TOKEN with your InfluxDB API token.
*/
const https = require('https');
@ -16,7 +18,7 @@ function queryWithToken() {
host: 'localhost:8086',
path: "/query?" + querystring.stringify(queryparams),
headers: {
'Authorization': 'Token YourAuthToken',
'Authorization': 'Token INFLUX_API_TOKEN',
'Content-type': 'application/json'
},
};

View File

@ -1,10 +1,12 @@
#######################################
# Use a token in the Authorization header
# to query the InfluxDB 1.x compatibility API
# to query the InfluxDB 1.x compatibility API.
#
# Replace INFLUX_API_TOKEN with your InfluxDB API token.
#######################################
curl --get "http://localhost:8086" \
--header "Authorization: Token YourAuthToken" \
--header "Authorization: Token INFLUX_API_TOKEN" \
--header 'Content-type: application/json' \
--data-urlencode "db=mydb" \
--data-urlencode "q=SELECT * FROM cpu_usage"