Merge 3bb1c9eb2a
into d177f373f9
commit
55686b4b94
|
@ -10,7 +10,5 @@ apis:
|
||||||
root: v2/ref.yml
|
root: v2/ref.yml
|
||||||
x-influxdata-docs-aliases:
|
x-influxdata-docs-aliases:
|
||||||
- /influxdb/v2/api/
|
- /influxdb/v2/api/
|
||||||
v1-compatibility@2:
|
- /influxdb/v2/api/v1-compatibility/
|
||||||
root: v1-compatibility/swaggerV1Compat.yml
|
|
||||||
x-influxdata-docs-aliases:
|
|
||||||
- /influxdb/v2/api/v1/
|
- /influxdb/v2/api/v1/
|
||||||
|
|
|
@ -6,5 +6,6 @@
|
||||||
- Headers
|
- Headers
|
||||||
- Pagination
|
- Pagination
|
||||||
- Response codes
|
- Response codes
|
||||||
|
- Compatibility endpoints
|
||||||
- name: All endpoints
|
- name: All endpoints
|
||||||
tags: []
|
tags: []
|
||||||
|
|
|
@ -58,6 +58,7 @@ tags:
|
||||||
- [Manage API tokens](/influxdb/v2/security/tokens/)
|
- [Manage API tokens](/influxdb/v2/security/tokens/)
|
||||||
- [Assign a token to a specific user](/influxdb/v2/security/tokens/create-token/)
|
- [Assign a token to a specific user](/influxdb/v2/security/tokens/create-token/)
|
||||||
name: Authorizations (API tokens)
|
name: Authorizations (API tokens)
|
||||||
|
- name: Authorizations (v1-compatible)
|
||||||
- name: Backup
|
- name: Backup
|
||||||
- description: |
|
- description: |
|
||||||
Store your data in InfluxDB [buckets](/influxdb/v2/reference/glossary/#bucket).
|
Store your data in InfluxDB [buckets](/influxdb/v2/reference/glossary/#bucket).
|
||||||
|
@ -88,6 +89,15 @@ tags:
|
||||||
| `orgID` | 16-byte string | The organization ID ([find your organization](/influxdb/v2/organizations/view-orgs/). |
|
| `orgID` | 16-byte string | The organization ID ([find your organization](/influxdb/v2/organizations/view-orgs/). |
|
||||||
name: Common parameters
|
name: Common parameters
|
||||||
x-traitTag: true
|
x-traitTag: true
|
||||||
|
- name: Compatibility endpoints
|
||||||
|
description: |
|
||||||
|
InfluxDB v2 provides a v1-compatible API for backward compatibility with InfluxDB 1.x clients and integrations.
|
||||||
|
|
||||||
|
Use these endpoints with InfluxDB 1.x client libraries and third-party integrations such as Grafana, Telegraf, and other tools designed for InfluxDB 1.x. The compatibility layer maps InfluxDB 1.x concepts (databases, retention policies) to InfluxDB v2 resources (buckets, organizations) through database retention policy (DBRP) mappings.
|
||||||
|
|
||||||
|
- [Write data (v1-compatible)](#tag/Write-data-(v1-compatible))
|
||||||
|
- [Query data using InfluxQL (v1-compatible)](#tag/Query-data-(v1-compatible))
|
||||||
|
- [Manage v1-compatible users and permissions](#tag/Authorizations-(v1-compatible))
|
||||||
- name: Config
|
- name: Config
|
||||||
- name: Dashboards
|
- name: Dashboards
|
||||||
- name: Data I/O endpoints
|
- name: Data I/O endpoints
|
||||||
|
@ -99,7 +109,7 @@ tags:
|
||||||
databases and retention policies are mapped to buckets using the
|
databases and retention policies are mapped to buckets using the
|
||||||
database and retention policy (DBRP) mapping service.
|
database and retention policy (DBRP) mapping service.
|
||||||
The DBRP mapping service uses the database and retention policy
|
The DBRP mapping service uses the database and retention policy
|
||||||
specified in 1.x compatibility API requests to route operations to a bucket.
|
specified in v1 compatibility API requests to route operations to a bucket.
|
||||||
|
|
||||||
### Related guides
|
### Related guides
|
||||||
|
|
||||||
|
@ -139,9 +149,6 @@ tags:
|
||||||
x-traitTag: true
|
x-traitTag: true
|
||||||
- name: Health
|
- name: Health
|
||||||
- name: Labels
|
- name: Labels
|
||||||
- name: Legacy Authorizations
|
|
||||||
- name: Legacy Query
|
|
||||||
- name: Legacy Write
|
|
||||||
- name: Metrics
|
- name: Metrics
|
||||||
- name: NotificationEndpoints
|
- name: NotificationEndpoints
|
||||||
- name: NotificationRules
|
- name: NotificationRules
|
||||||
|
@ -194,6 +201,7 @@ tags:
|
||||||
- description: |
|
- description: |
|
||||||
Retrieve data, analyze queries, and get query suggestions.
|
Retrieve data, analyze queries, and get query suggestions.
|
||||||
name: Query
|
name: Query
|
||||||
|
- name: Query data (v1-compatible)
|
||||||
- description: |
|
- description: |
|
||||||
See the [**API Quick Start**](/influxdb/v2/api-guide/api_intro/)
|
See the [**API Quick Start**](/influxdb/v2/api-guide/api_intro/)
|
||||||
to get up and running authenticating with tokens, writing to buckets, and querying data.
|
to get up and running authenticating with tokens, writing to buckets, and querying data.
|
||||||
|
@ -314,6 +322,7 @@ tags:
|
||||||
- description: |
|
- description: |
|
||||||
Write time series data to [buckets](/influxdb/v2/reference/glossary/#bucket).
|
Write time series data to [buckets](/influxdb/v2/reference/glossary/#bucket).
|
||||||
name: Write
|
name: Write
|
||||||
|
- name: Write data (v1-compatible)
|
||||||
paths:
|
paths:
|
||||||
/api/v2:
|
/api/v2:
|
||||||
get:
|
get:
|
||||||
|
@ -12756,7 +12765,7 @@ paths:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Error'
|
$ref: '#/components/schemas/Error'
|
||||||
description: The request was well-formed, but some or all the points were rejected due to semantic errors--for example, schema conflicts or retention policy violations. Error message contains details for one or more rejected points.
|
description: The request was well-formed, but some or all the points were rejected due to semantic errors--for example, schema conflicts or retention policy violations. Error message contains details for one or more rejected points.
|
||||||
'429':
|
'429':
|
||||||
description: |
|
description: |
|
||||||
|
@ -12869,7 +12878,7 @@ paths:
|
||||||
description: Unexpected error
|
description: Unexpected error
|
||||||
summary: List all legacy authorizations
|
summary: List all legacy authorizations
|
||||||
tags:
|
tags:
|
||||||
- Legacy Authorizations
|
- Authorizations (v1-compatible)
|
||||||
post:
|
post:
|
||||||
description: |
|
description: |
|
||||||
Creates a legacy authorization and returns the legacy authorization.
|
Creates a legacy authorization and returns the legacy authorization.
|
||||||
|
@ -12932,7 +12941,7 @@ paths:
|
||||||
description: Unexpected error
|
description: Unexpected error
|
||||||
summary: Create a legacy authorization
|
summary: Create a legacy authorization
|
||||||
tags:
|
tags:
|
||||||
- Legacy Authorizations
|
- Authorizations (v1-compatible)
|
||||||
servers:
|
servers:
|
||||||
- url: /private
|
- url: /private
|
||||||
/legacy/authorizations/{authID}:
|
/legacy/authorizations/{authID}:
|
||||||
|
@ -12954,7 +12963,7 @@ paths:
|
||||||
description: Unexpected error
|
description: Unexpected error
|
||||||
summary: Delete a legacy authorization
|
summary: Delete a legacy authorization
|
||||||
tags:
|
tags:
|
||||||
- Legacy Authorizations
|
- Authorizations (v1-compatible)
|
||||||
get:
|
get:
|
||||||
operationId: GetLegacyAuthorizationsID
|
operationId: GetLegacyAuthorizationsID
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -12977,7 +12986,7 @@ paths:
|
||||||
description: Unexpected error
|
description: Unexpected error
|
||||||
summary: Retrieve a legacy authorization
|
summary: Retrieve a legacy authorization
|
||||||
tags:
|
tags:
|
||||||
- Legacy Authorizations
|
- Authorizations (v1-compatible)
|
||||||
patch:
|
patch:
|
||||||
operationId: PatchLegacyAuthorizationsID
|
operationId: PatchLegacyAuthorizationsID
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -13007,7 +13016,7 @@ paths:
|
||||||
description: Unexpected error
|
description: Unexpected error
|
||||||
summary: Update a legacy authorization to be active or inactive
|
summary: Update a legacy authorization to be active or inactive
|
||||||
tags:
|
tags:
|
||||||
- Legacy Authorizations
|
- Authorizations (v1-compatible)
|
||||||
servers:
|
servers:
|
||||||
- url: /private
|
- url: /private
|
||||||
/legacy/authorizations/{authID}/password:
|
/legacy/authorizations/{authID}/password:
|
||||||
|
@ -13040,94 +13049,29 @@ paths:
|
||||||
description: Unexpected error
|
description: Unexpected error
|
||||||
summary: Set a legacy authorization password
|
summary: Set a legacy authorization password
|
||||||
tags:
|
tags:
|
||||||
- Legacy Authorizations
|
- Authorizations (v1-compatible)
|
||||||
servers:
|
servers:
|
||||||
- url: /private
|
- url: /private
|
||||||
/query:
|
/query:
|
||||||
get:
|
get:
|
||||||
description: Queries InfluxDB using InfluxQL.
|
summary: Execute InfluxQL query (v1-compatible)
|
||||||
|
description: |
|
||||||
|
Executes an InfluxQL query to retrieve data from the specified database.
|
||||||
|
|
||||||
|
This endpoint is compatible with InfluxDB 1.x client libraries and third-party integrations such as Grafana.
|
||||||
|
Use query parameters to specify the database and the InfluxQL query.
|
||||||
operationId: GetLegacyQuery
|
operationId: GetLegacyQuery
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: '#/components/parameters/TraceSpan'
|
- $ref: '#/components/parameters/TraceSpan'
|
||||||
- in: header
|
- $ref: '#/components/parameters/AuthV1Username'
|
||||||
name: Accept
|
- $ref: '#/components/parameters/AuthV1Password'
|
||||||
schema:
|
- $ref: '#/components/parameters/Accept'
|
||||||
default: application/json
|
- $ref: '#/components/parameters/AcceptEncoding'
|
||||||
description: |
|
- $ref: '#/components/parameters/Content-Type'
|
||||||
Media type that the client can understand.
|
- $ref: '#/components/parameters/V1Database'
|
||||||
|
- $ref: '#/components/parameters/V1RetentionPolicy'
|
||||||
**Note**: With `application/csv`, query results include [**unix timestamps**](/influxdb/v2/reference/glossary/#unix-timestamp) instead of [RFC3339 timestamps](/influxdb/v2/reference/glossary/#rfc3339-timestamp).
|
- $ref: '#/components/parameters/V1Epoch'
|
||||||
enum:
|
- $ref: '#/components/parameters/V1Query'
|
||||||
- application/json
|
|
||||||
- application/csv
|
|
||||||
- text/csv
|
|
||||||
- application/x-msgpack
|
|
||||||
type: string
|
|
||||||
- description: The content encoding (usually a compression algorithm) that the client can understand.
|
|
||||||
in: header
|
|
||||||
name: Accept-Encoding
|
|
||||||
schema:
|
|
||||||
default: identity
|
|
||||||
description: The content coding. Use `gzip` for compressed data or `identity` for unmodified, uncompressed data.
|
|
||||||
enum:
|
|
||||||
- gzip
|
|
||||||
- identity
|
|
||||||
type: string
|
|
||||||
- in: header
|
|
||||||
name: Content-Type
|
|
||||||
schema:
|
|
||||||
enum:
|
|
||||||
- application/json
|
|
||||||
type: string
|
|
||||||
- description: The InfluxDB 1.x username to authenticate the request.
|
|
||||||
in: query
|
|
||||||
name: u
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
- description: The InfluxDB 1.x password to authenticate the request.
|
|
||||||
in: query
|
|
||||||
name: p
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
- description: |
|
|
||||||
The database to query data from.
|
|
||||||
This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket).
|
|
||||||
For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/).
|
|
||||||
in: query
|
|
||||||
name: db
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
- description: |
|
|
||||||
The retention policy to query data from.
|
|
||||||
This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket).
|
|
||||||
For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/).
|
|
||||||
in: query
|
|
||||||
name: rp
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
- description: The InfluxQL query to execute. To execute multiple queries, delimit queries with a semicolon (`;`).
|
|
||||||
in: query
|
|
||||||
name: q
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
- description: |
|
|
||||||
A unix timestamp precision.
|
|
||||||
Formats timestamps as [unix (epoch) timestamps](/influxdb/v2/reference/glossary/#unix-timestamp) with the specified precision
|
|
||||||
instead of [RFC3339 timestamps](/influxdb/v2/reference/glossary/#rfc3339-timestamp) with nanosecond precision.
|
|
||||||
in: query
|
|
||||||
name: epoch
|
|
||||||
schema:
|
|
||||||
enum:
|
|
||||||
- ns
|
|
||||||
- u
|
|
||||||
- µ
|
|
||||||
- ms
|
|
||||||
- s
|
|
||||||
- m
|
|
||||||
- h
|
|
||||||
type: string
|
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
content:
|
content:
|
||||||
|
@ -13191,19 +13135,87 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Error'
|
$ref: '#/components/schemas/Error'
|
||||||
description: Error processing query
|
description: Error processing query
|
||||||
summary: Query with the 1.x compatibility API
|
|
||||||
tags:
|
tags:
|
||||||
- Legacy Query
|
- Query data (v1-compatible)
|
||||||
|
post:
|
||||||
|
operationId: PostQueryV1
|
||||||
|
summary: Execute InfluxQL query (v1-compatible)
|
||||||
|
description: |
|
||||||
|
Executes an InfluxQL query to retrieve data from the specified database.
|
||||||
|
|
||||||
|
This endpoint is compatible with InfluxDB 1.x client libraries and third-party integrations such as Grafana.
|
||||||
|
Use query parameters to specify the database and the InfluxQL query.
|
||||||
|
tags:
|
||||||
|
- Query data (v1-compatible)
|
||||||
|
requestBody:
|
||||||
|
description: InfluxQL query to execute.
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
parameters:
|
||||||
|
- $ref: '#/components/parameters/TraceSpan'
|
||||||
|
- $ref: '#/components/parameters/AuthV1Username'
|
||||||
|
- $ref: '#/components/parameters/AuthV1Password'
|
||||||
|
- $ref: '#/components/parameters/Accept'
|
||||||
|
- $ref: '#/components/parameters/AcceptEncoding'
|
||||||
|
- $ref: '#/components/parameters/Content-Type'
|
||||||
|
- $ref: '#/components/parameters/V1Database'
|
||||||
|
- $ref: '#/components/parameters/V1RetentionPolicy'
|
||||||
|
- $ref: '#/components/parameters/V1Epoch'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Query results
|
||||||
|
headers:
|
||||||
|
Content-Encoding:
|
||||||
|
description: The Content-Encoding entity header is used to compress the media-type. When present, its value indicates which encodings were applied to the entity-body
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
description: Specifies that the response in the body is encoded with gzip or not encoded with identity.
|
||||||
|
default: identity
|
||||||
|
enum:
|
||||||
|
- gzip
|
||||||
|
- identity
|
||||||
|
Trace-Id:
|
||||||
|
description: The Trace-Id header reports the request's trace ID, if one was generated.
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
description: Specifies the request's trace ID.
|
||||||
|
content:
|
||||||
|
application/csv:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/InfluxqlCsvResponse'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/InfluxqlJsonResponse'
|
||||||
|
text/csv:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/InfluxqlCsvResponse'
|
||||||
|
examples:
|
||||||
|
influxql-chunk_size_2:
|
||||||
|
value: |
|
||||||
|
{"results":[{"statement_id":0,"series":[{"name":"mymeas","columns":["time","myfield","mytag"],"values":[["2016-05-19T18:37:55Z",90,"1"],["2016-05-19T18:37:56Z",90,"1"]],"partial":true}],"partial":true}]}
|
||||||
|
{"results":[{"statement_id":0,"series":[{"name":"mymeas","columns":["time","myfield","mytag"],"values":[["2016-05-19T18:37:57Z",90,"1"],["2016-05-19T18:37:58Z",90,"1"]]}]}]}
|
||||||
|
application/x-msgpack:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
'429':
|
||||||
|
description: Token is temporarily over quota. The Retry-After header describes when to try the read again.
|
||||||
|
headers:
|
||||||
|
Retry-After:
|
||||||
|
description: A non-negative decimal integer indicating the seconds to delay after the response is received.
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
default:
|
||||||
|
description: Error processing query
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Error'
|
||||||
/write:
|
/write:
|
||||||
post:
|
post:
|
||||||
description: |-
|
|
||||||
Writes line protocol to the specified bucket.
|
|
||||||
|
|
||||||
This endpoint provides backward compatibility for InfluxDB 1.x write workloads using tools such as InfluxDB 1.x client libraries, the Telegraf `outputs.influxdb` output plugin, or third-party tools.
|
|
||||||
|
|
||||||
Use this endpoint to send data in [line protocol](https://docs.influxdata.com/influxdb/v2/reference/syntax/line-protocol/) format to InfluxDB.
|
|
||||||
Use query parameters to specify options for writing data.
|
|
||||||
|
|
||||||
operationId: PostLegacyWrite
|
operationId: PostLegacyWrite
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: '#/components/parameters/TraceSpan'
|
- $ref: '#/components/parameters/TraceSpan'
|
||||||
|
@ -13281,7 +13293,7 @@ paths:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Error'
|
$ref: '#/components/schemas/Error'
|
||||||
description: The request was well-formed, but some or all the points were rejected due to semantic errors--for example, schema conflicts or retention policy violations. Error message contains details for one or more rejected points.
|
description: The request was well-formed, but some or all the points were rejected due to semantic errors--for example, schema conflicts or retention policy violations. Error message contains details for one or more rejected points.
|
||||||
'429':
|
'429':
|
||||||
description: Token is temporarily over quota. The Retry-After header describes when to try the write again.
|
description: Token is temporarily over quota. The Retry-After header describes when to try the write again.
|
||||||
|
@ -13305,9 +13317,31 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Error'
|
$ref: '#/components/schemas/Error'
|
||||||
description: Internal server error
|
description: Internal server error
|
||||||
summary: Write time series data into InfluxDB in a V1-compatible format
|
summary: Write data using a v1-compatible request
|
||||||
|
description: |
|
||||||
|
Writes data in [line protocol](/influxdb/v2/reference/syntax/line-protocol/) syntax to the specified bucket using a v1-compatible request.
|
||||||
|
|
||||||
|
This endpoint provides backward compatibility for InfluxDB 1.x write workloads using tools such as InfluxDB 1.x client libraries, the Telegraf `outputs.influxdb` output plugin, or third-party tools.
|
||||||
|
|
||||||
|
Use query parameters to specify options for writing data.
|
||||||
|
|
||||||
|
#### InfluxDB Cloud
|
||||||
|
|
||||||
|
- Validates and queues the request.
|
||||||
|
- Handles the write asynchronously - the write might not have completed yet.
|
||||||
|
- Returns a `Retry-After` header that describes when to try the write again.
|
||||||
|
|
||||||
|
#### InfluxDB OSS v2
|
||||||
|
|
||||||
|
- Validates the request and handles the write synchronously.
|
||||||
|
- If all points were written successfully, responds with HTTP `2xx` status code
|
||||||
|
- If any points were rejected, responds with HTTP `4xx` status code and details about the problem.
|
||||||
|
|
||||||
|
#### Related guides
|
||||||
|
|
||||||
|
- [Write data with the InfluxDB API](/influxdb/v2/write-data/developer-tools/api)
|
||||||
tags:
|
tags:
|
||||||
- Legacy Write
|
- Write data (v1-compatible)
|
||||||
components:
|
components:
|
||||||
examples:
|
examples:
|
||||||
AuthorizationPostRequest:
|
AuthorizationPostRequest:
|
||||||
|
@ -13412,6 +13446,96 @@ components:
|
||||||
required: false
|
required: false
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
Accept:
|
||||||
|
in: header
|
||||||
|
name: Accept
|
||||||
|
schema:
|
||||||
|
default: application/json
|
||||||
|
description: |
|
||||||
|
Media type that the client can understand.
|
||||||
|
|
||||||
|
**Note**: With `application/csv`, query results include [**unix timestamps**](/influxdb/v2/reference/glossary/#unix-timestamp) instead of [RFC3339 timestamps](/influxdb/v2/reference/glossary/#rfc3339-timestamp).
|
||||||
|
enum:
|
||||||
|
- application/json
|
||||||
|
- application/csv
|
||||||
|
- text/csv
|
||||||
|
- application/x-msgpack
|
||||||
|
type: string
|
||||||
|
AcceptEncoding:
|
||||||
|
description: The content encoding (usually a compression algorithm) that the client can understand.
|
||||||
|
in: header
|
||||||
|
name: Accept-Encoding
|
||||||
|
schema:
|
||||||
|
default: identity
|
||||||
|
description: The content coding. Use `gzip` for compressed data or `identity` for unmodified, uncompressed data.
|
||||||
|
enum:
|
||||||
|
- gzip
|
||||||
|
- identity
|
||||||
|
type: string
|
||||||
|
Content-Type:
|
||||||
|
in: header
|
||||||
|
name: Content-Type
|
||||||
|
schema:
|
||||||
|
enum:
|
||||||
|
- application/json
|
||||||
|
type: string
|
||||||
|
AuthV1Username:
|
||||||
|
description: |
|
||||||
|
The InfluxDB 1.x username to authenticate the request.
|
||||||
|
If you provide an API token as the password, `u` is required, but can be any value.
|
||||||
|
in: query
|
||||||
|
name: u
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
AuthV1Password:
|
||||||
|
description: The InfluxDB 1.x password to authenticate the request.
|
||||||
|
in: query
|
||||||
|
name: p
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
V1Database:
|
||||||
|
description: |
|
||||||
|
The database to query data from.
|
||||||
|
This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket).
|
||||||
|
For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/).
|
||||||
|
in: query
|
||||||
|
name: db
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
V1RetentionPolicy:
|
||||||
|
description: |
|
||||||
|
The retention policy to query data from.
|
||||||
|
This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket).
|
||||||
|
For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/).
|
||||||
|
in: query
|
||||||
|
name: rp
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
V1Query:
|
||||||
|
description: The InfluxQL query to execute. To execute multiple queries, delimit queries with a semicolon (`;`).
|
||||||
|
in: query
|
||||||
|
name: q
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
V1Epoch:
|
||||||
|
description: |
|
||||||
|
A unix timestamp precision.
|
||||||
|
Formats timestamps as [unix (epoch) timestamps](/influxdb/v2/reference/glossary/#unix-timestamp) with the specified precision
|
||||||
|
instead of [RFC3339 timestamps](/influxdb/v2/reference/glossary/#rfc3339-timestamp) with nanosecond precision.
|
||||||
|
in: query
|
||||||
|
name: epoch
|
||||||
|
schema:
|
||||||
|
enum:
|
||||||
|
- ns
|
||||||
|
- u
|
||||||
|
- µ
|
||||||
|
- ms
|
||||||
|
- s
|
||||||
|
- m
|
||||||
|
- h
|
||||||
|
type: string
|
||||||
responses:
|
responses:
|
||||||
AuthorizationError:
|
AuthorizationError:
|
||||||
content:
|
content:
|
||||||
|
@ -20058,13 +20182,16 @@ x-tagGroups:
|
||||||
- Headers
|
- Headers
|
||||||
- Pagination
|
- Pagination
|
||||||
- Response codes
|
- Response codes
|
||||||
|
- Compatibility endpoints
|
||||||
- name: All endpoints
|
- name: All endpoints
|
||||||
tags:
|
tags:
|
||||||
- Authorizations (API tokens)
|
- Authorizations (API tokens)
|
||||||
|
- Authorizations (v1-compatible)
|
||||||
- Backup
|
- Backup
|
||||||
- Buckets
|
- Buckets
|
||||||
- Cells
|
- Cells
|
||||||
- Checks
|
- Checks
|
||||||
|
- Compatibility endpoints
|
||||||
- Config
|
- Config
|
||||||
- Dashboards
|
- Dashboards
|
||||||
- DBRPs
|
- DBRPs
|
||||||
|
@ -20072,15 +20199,13 @@ x-tagGroups:
|
||||||
- Delete
|
- Delete
|
||||||
- Health
|
- Health
|
||||||
- Labels
|
- Labels
|
||||||
- Legacy Authorizations
|
|
||||||
- Legacy Query
|
|
||||||
- Legacy Write
|
|
||||||
- Metrics
|
- Metrics
|
||||||
- NotificationEndpoints
|
- NotificationEndpoints
|
||||||
- NotificationRules
|
- NotificationRules
|
||||||
- Organizations
|
- Organizations
|
||||||
- Ping
|
- Ping
|
||||||
- Query
|
- Query
|
||||||
|
- Query data (v1-compatible)
|
||||||
- Ready
|
- Ready
|
||||||
- RemoteConnections
|
- RemoteConnections
|
||||||
- Replications
|
- Replications
|
||||||
|
@ -20102,3 +20227,4 @@ x-tagGroups:
|
||||||
- Variables
|
- Variables
|
||||||
- Views
|
- Views
|
||||||
- Write
|
- Write
|
||||||
|
- Write data (v1-compatible)
|
||||||
|
|
|
@ -34,8 +34,8 @@ and visit the `/docs` endpoint in a browser ([localhost:8086/docs](http://localh
|
||||||
|
|
||||||
## InfluxDB v1 compatibility API documentation
|
## InfluxDB v1 compatibility API documentation
|
||||||
|
|
||||||
The InfluxDB v2 API includes [InfluxDB 1.x compatibility endpoints](/influxdb/v2/reference/api/influxdb-1x/)
|
The InfluxDB v2 API includes [InfluxDB v1 compatibility endpoints and authentication](/influxdb/v2/api-guide/influxdb-1x/)
|
||||||
that work with InfluxDB 1.x client libraries and third-party integrations like
|
that work with InfluxDB 1.x client libraries and third-party integrations like
|
||||||
[Grafana](https://grafana.com) and others.
|
[Grafana](https://grafana.com) and others.
|
||||||
|
|
||||||
<a class="btn" href="/influxdb/v2/api/v1-compatibility/">View full v1 compatibility API documentation</a>
|
<a class="btn" href="/influxdb/v2/api/v2/#tag/Compatibility-endpoints">View full v1 compatibility API documentation</a>
|
||||||
|
|
|
@ -14,4 +14,5 @@ source: /shared/influxdb-v2/api-guide/api_intro.md
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- The content for this file is located at
|
<!-- The content for this file is located at
|
||||||
// SOURCE content/shared/influxdb-v2/api-guide/api_intro.md -->
|
// SOURCE content/shared/influxdb-v2/api-guide/api_intro.md
|
||||||
|
-->
|
||||||
|
|
|
@ -18,4 +18,5 @@ source: /shared/influxdb-v2/api-guide/influxdb-1x/_index.md
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- The content for this file is located at
|
<!-- The content for this file is located at
|
||||||
// SOURCE content/shared/influxdb-v2/api-guide/influxdb-1x/_index.md -->
|
// SOURCE content/shared/influxdb-v2/api-guide/influxdb-1x/_index.md
|
||||||
|
-->
|
||||||
|
|
|
@ -14,17 +14,15 @@ list_code_example: |
|
||||||
<span class="api get">GET</span> http://localhost:8086/query
|
<span class="api get">GET</span> http://localhost:8086/query
|
||||||
</pre>
|
</pre>
|
||||||
related:
|
related:
|
||||||
|
- /influxdb/v2/query-data/execute-queries/influx-api/
|
||||||
- /influxdb/v2/query-data/influxql
|
- /influxdb/v2/query-data/influxql
|
||||||
aliases:
|
aliases:
|
||||||
- /influxdb/v2/reference/api/influxdb-1x/query/
|
- /influxdb/v2/reference/api/influxdb-1x/query/
|
||||||
---
|
---
|
||||||
|
|
||||||
The `/query` 1.x compatibility endpoint queries InfluxDB {{< current-version >}} using **InfluxQL**.
|
The `/query` 1.x compatibility endpoint queries InfluxDB {{< current-version >}} using **InfluxQL**.
|
||||||
Use the `GET` request method to query data from the `/query` endpoint.
|
Send an InfluxQL query in an HTTP `GET` or `POST` request to query data from the `/query` endpoint.
|
||||||
|
|
||||||
<pre>
|
|
||||||
<span class="api get">GET</span> http://localhost:8086/query
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
The `/query` compatibility endpoint uses the **database** and **retention policy**
|
The `/query` compatibility endpoint uses the **database** and **retention policy**
|
||||||
specified in the query request to map the request to an InfluxDB bucket.
|
specified in the query request to map the request to an InfluxDB bucket.
|
||||||
|
@ -32,31 +30,32 @@ For more information, see [Database and retention policy mapping](/influxdb/v2/r
|
||||||
|
|
||||||
{{% show-in "cloud,cloud-serverless" %}}
|
{{% show-in "cloud,cloud-serverless" %}}
|
||||||
|
|
||||||
{{% note %}}
|
> [!Note]
|
||||||
If you have an existing bucket that doesn't follow the **database/retention-policy** naming convention,
|
> 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/query-data/influxql/dbrp/#create-dbrp-mappings)
|
> you **must** [manually create a database and retention policy mapping](/influxdb/v2/query-data/influxql/dbrp/#create-dbrp-mappings)
|
||||||
to query that bucket with the `/query` compatibility API.
|
> to query that bucket with the `/query` compatibility API.
|
||||||
{{% /note %}}
|
|
||||||
|
|
||||||
{{% /show-in %}}
|
{{% /show-in %}}
|
||||||
|
|
||||||
## Authentication
|
## Authentication
|
||||||
|
|
||||||
Use one of the following authentication methods:
|
Use one of the following authentication methods:
|
||||||
* **token authentication**
|
|
||||||
* **basic authentication with username and password**
|
|
||||||
* **query string authentication with username and password**
|
|
||||||
|
|
||||||
_For more information, see [Authentication](/influxdb/v2/reference/api/influxdb-1x/#authentication)._
|
- the 2.x `Authorization: Token` scheme in the header
|
||||||
|
- the v1-compatible `u` and `p` query string parameters
|
||||||
|
- the v1-compatible `Basic` authentication scheme in the header
|
||||||
|
|
||||||
|
For more information, see [Authentication for the 1.x compatibility API](/influxdb/v2/api-guide/influxdb-1x/).
|
||||||
|
|
||||||
## Query string parameters
|
## Query string parameters
|
||||||
|
|
||||||
### u
|
### u
|
||||||
(Optional) The 1.x **username** to authenticate the request.
|
(Optional) The 1.x **username** to authenticate the request.
|
||||||
|
If you provide an API token as the password, `u` is required, but can be any value.
|
||||||
_See [query string authentication](/influxdb/v2/reference/api/influxdb-1x/#query-string-authentication)._
|
_See [query string authentication](/influxdb/v2/reference/api/influxdb-1x/#query-string-authentication)._
|
||||||
|
|
||||||
### p
|
### p
|
||||||
(Optional) The 1.x **password** to authenticate the request.
|
(Optional) The 1.x **password** or the 2.x API token to authenticate the request.
|
||||||
_See [query string authentication](/influxdb/v2/reference/api/influxdb-1x/#query-string-authentication)._
|
_See [query string authentication](/influxdb/v2/reference/api/influxdb-1x/#query-string-authentication)._
|
||||||
|
|
||||||
### db
|
### db
|
||||||
|
@ -94,61 +93,65 @@ The following precisions are available:
|
||||||
- [Return query results with millisecond Unix timestamps](#return-query-results-with-millisecond-unix-timestamps)
|
- [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)
|
- [Execute InfluxQL queries from a file](#execute-influxql-queries-from-a-file)
|
||||||
|
|
||||||
{{% code-placeholders "API_TOKEN" %}}
|
{{% code-placeholders "INFLUX_USERNAME|INFLUX_PASSWORD_OR_TOKEN|API_TOKEN" %}}
|
||||||
|
|
||||||
##### Query using basic authentication
|
##### Query using basic authentication
|
||||||
|
|
||||||
|
The following example:
|
||||||
|
|
||||||
|
- sends a `GET` request to the `/query` endpoint
|
||||||
|
- uses the `Authorization` header with the `Basic` scheme (compatible with InfluxDB 1.x) to provide username and password credentials
|
||||||
|
- uses the default retention policy for the database
|
||||||
|
|
||||||
{{% show-in "v2" %}}
|
{{% show-in "v2" %}}
|
||||||
|
|
||||||
{{< code-tabs-wrapper >}}
|
|
||||||
{{% code-tabs %}}
|
|
||||||
[curl](#curl)
|
|
||||||
[Node.js](#nodejs)
|
|
||||||
{{% /code-tabs %}}
|
|
||||||
{{% code-tab-content %}}
|
|
||||||
|
|
||||||
<!--pytest.mark.skip-->
|
<!--pytest.mark.skip-->
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
{{% get-shared-text "api/v1-compat/auth/oss/basic-auth.sh" %}}
|
##############################################################################
|
||||||
```
|
# Use Basic authentication with an
|
||||||
{{% /code-tab-content %}}
|
# InfluxDB v1-compatible username and password
|
||||||
{{% code-tab-content %}}
|
# to query the InfluxDB 1.x compatibility API.
|
||||||
```js
|
#
|
||||||
{{% get-shared-text "api/v1-compat/auth/oss/basic-auth.js" %}}
|
# INFLUX_USERNAME: your v1-compatible username.
|
||||||
```
|
# INFLUX_PASSWORD_OR_TOKEN: your API token or v1-compatible password.
|
||||||
{{% /code-tab-content %}}
|
##############################################################################
|
||||||
{{< /code-tabs-wrapper >}}
|
|
||||||
|
|
||||||
|
curl --get "http://{{< influxdb/host >}}/query" \
|
||||||
|
--user "INFLUX_USERNAME":"INFLUX_PASSWORD_OR_TOKEN" \
|
||||||
|
--data-urlencode "db=BUCKET_NAME" \
|
||||||
|
--data-urlencode "q=SELECT * FROM cpu_usage"
|
||||||
|
```
|
||||||
{{% /show-in %}}
|
{{% /show-in %}}
|
||||||
|
|
||||||
{{% show-in "cloud,cloud-serverless" %}}
|
{{% show-in "cloud,cloud-serverless" %}}
|
||||||
|
|
||||||
{{< code-tabs-wrapper >}}
|
|
||||||
{{% code-tabs %}}
|
|
||||||
[curl](#curl)
|
|
||||||
[Node.js](#nodejs)
|
|
||||||
{{% /code-tabs %}}
|
|
||||||
{{% code-tab-content %}}
|
|
||||||
|
|
||||||
<!--pytest.mark.skip-->
|
<!--pytest.mark.skip-->
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.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 >}}
|
|
||||||
|
|
||||||
|
|
||||||
{{% /show-in %}}
|
{{% /show-in %}}
|
||||||
|
|
||||||
|
##### Query using an HTTP POST request
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl \
|
||||||
|
--request POST \
|
||||||
|
"http://{{< influxdb/host >}}/query?db=DATABASE_NAME&rp=RETENTION_POLICY" \
|
||||||
|
--user "INFLUX_USERNAME":"INFLUX_PASSWORD_OR_TOKEN" \
|
||||||
|
--header "Content-type: application/vnd.influxql" \
|
||||||
|
--data "SELECT * FROM cpu_usage WHERE time > now() - 1h"
|
||||||
|
```
|
||||||
|
|
||||||
##### Query a non-default retention policy
|
##### Query a non-default retention policy
|
||||||
|
|
||||||
|
The following example:
|
||||||
|
|
||||||
|
- sends a `GET` request to the `/query` endpoint
|
||||||
|
- uses the `Authorization` header with the `Token` scheme (compatible with InfluxDB 2.x) to provide the API token
|
||||||
|
- queries a custom retention policy mapped for the database
|
||||||
|
|
||||||
<!--test:setup
|
<!--test:setup
|
||||||
```sh
|
```sh
|
||||||
service influxdb start && \
|
service influxdb start && \
|
||||||
|
@ -162,43 +165,56 @@ influx setup \
|
||||||
-->
|
-->
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl --get http://localhost:8086/query \
|
curl --get http://{{< influxdb/host >}}/query \
|
||||||
--header "Authorization: Token API_TOKEN" \
|
--header "Authorization: Token API_TOKEN" \
|
||||||
--data-urlencode "db=mydb" \
|
--data-urlencode "db=DATABASE_NAME" \
|
||||||
--data-urlencode "rp=customrp" \
|
--data-urlencode "rp=RETENTION_POLICY_NAME" \
|
||||||
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
|
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Execute multiple queries
|
##### Execute multiple queries
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl --get http://localhost:8086/query \
|
curl --get http://{{< influxdb/host >}}/query \
|
||||||
--header "Authorization: Token API_TOKEN" \
|
--header "Authorization: Token API_TOKEN" \
|
||||||
--data-urlencode "db=mydb" \
|
--data-urlencode "db=DATABASE_NAME" \
|
||||||
--data-urlencode "q=SELECT * FROM mem WHERE host=host1;SELECT mean(used_percent) FROM mem WHERE host=host1 GROUP BY time(10m)"
|
--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
|
##### Return query results with millisecond Unix timestamps
|
||||||
```sh
|
```sh
|
||||||
curl --get http://localhost:8086/query \
|
curl --get http://{{< influxdb/host >}}/query \
|
||||||
--header "Authorization: Token API_TOKEN" \
|
--header "Authorization: Token API_TOKEN" \
|
||||||
--data-urlencode "db=mydb" \
|
--data-urlencode "db=DATABASE_NAME" \
|
||||||
--data-urlencode "rp=myrp" \
|
--data-urlencode "rp=RETENTION_POLICY_NAME" \
|
||||||
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1" \
|
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1" \
|
||||||
--data-urlencode "epoch=ms"
|
--data-urlencode "epoch=ms"
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Execute InfluxQL queries from a file
|
##### Execute InfluxQL queries from a file
|
||||||
```sh
|
```sh
|
||||||
curl --get http://localhost:8086/query \
|
curl --get http://{{< influxdb/host >}}/query \
|
||||||
--header "Authorization: Token API_TOKEN" \
|
--header "Authorization: Token API_TOKEN" \
|
||||||
--data-urlencode "db=mydb" \
|
--data-urlencode "db=DATABASE_NAME" \
|
||||||
--data-urlencode "q@path/to/influxql.txt" \
|
--data-urlencode "q@path/to/influxql.txt"
|
||||||
--data-urlencode "async=true"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return a gzip-compressed response
|
||||||
|
```sh
|
||||||
|
curl --get http://{{< influxdb/host >}}/query \
|
||||||
|
--header 'Accept-Encoding: gzip' \
|
||||||
|
--header "Authorization: Token API_TOKEN" \
|
||||||
|
--data-urlencode "db=DATABASE_NAME" \
|
||||||
|
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
|
||||||
|
```
|
||||||
{{% /code-placeholders %}}
|
{{% /code-placeholders %}}
|
||||||
|
|
||||||
Replace the following:
|
Replace the following:
|
||||||
|
|
||||||
- {{% code-placeholder-key %}}`API_TOKEN`{{% /code-placeholder-key %}}: your InfluxDB [API token](/influxdb/v2/admin/tokens/)
|
- {{% code-placeholder-key %}}`API_TOKEN`{{% /code-placeholder-key %}}: your InfluxDB [API token](/influxdb/v2/admin/tokens/)
|
||||||
|
- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}: the name of the database to query.
|
||||||
|
In InfluxDB 2.x, databases and retention policies map to [buckets](/influxdb/v2/admin/buckets/).
|
||||||
|
- {{% code-placeholder-key %}}`RETENTION_POLICY_NAME`{{% /code-placeholder-key %}}: the name of the retention policy to query.
|
||||||
|
In InfluxDB 2.x, databases and retention policies map to [buckets](/influxdb/v2/admin/buckets/).
|
||||||
|
|
||||||
|
_For more information about the database and retention policy mapping, see [Database and retention policy mapping](/influxdb/v2/reference/api/influxdb-1x/dbrp)._
|
|
@ -12,4 +12,5 @@ source: /shared/influxdb-v2/api-guide/tutorials/_index.md
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- The content for this file is located at
|
<!-- The content for this file is located at
|
||||||
// SOURCE content/shared/influxdb-v2/api-guide/tutorials/_index.md -->
|
// SOURCE content/shared/influxdb-v2/api-guide/tutorials/_index.md
|
||||||
|
-->
|
||||||
|
|
|
@ -328,6 +328,6 @@ which requires authentication.
|
||||||
|
|
||||||
**For these external clients to work with InfluxDB {{< current-version >}}:**
|
**For these external clients to work with InfluxDB {{< current-version >}}:**
|
||||||
|
|
||||||
1. [Manually create a 1.x-compatible authorization](/influxdb/v2/upgrade/v1-to-v2/manual-upgrade/#create-a-1x-compatible-authorization).
|
1. [Manually create a v1-compatible authorization](/influxdb/v2/upgrade/v1-to-v2/manual-upgrade/#create-a-1x-compatible-authorization).
|
||||||
2. Update the client configuration to use the username and password associated
|
2. Update the client configuration to use the username and password associated
|
||||||
with your 1.x-compatible authorization.
|
with your v1-compatible authorization.
|
||||||
|
|
|
@ -3,7 +3,7 @@ title: Manually upgrade from InfluxDB 1.x to 2.7
|
||||||
list_title: Manually upgrade from 1.x to 2.7
|
list_title: Manually upgrade from 1.x to 2.7
|
||||||
description: >
|
description: >
|
||||||
To manually upgrade from InfluxDB 1.x to InfluxDB 2.7, migrate data, create
|
To manually upgrade from InfluxDB 1.x to InfluxDB 2.7, migrate data, create
|
||||||
1.x-compatible authorizations, and create database and retention policy
|
v1-compatible authorizations, and create database and retention policy
|
||||||
(DBRP) mappings.
|
(DBRP) mappings.
|
||||||
menu:
|
menu:
|
||||||
influxdb_v2:
|
influxdb_v2:
|
||||||
|
|
|
@ -11,4 +11,5 @@ source: /shared/influxdb-v2/query-data/execute-queries/influx-api.md
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- The content for this file is located at
|
<!-- The content for this file is located at
|
||||||
// SOURCE content/shared/influxdb-v2/query-data/execute-queries/influx-api.md -->
|
// SOURCE content/shared/influxdb-v2/query-data/execute-queries/influx-api.md
|
||||||
|
-->
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
---
|
---
|
||||||
title: Query data with InfluxQL
|
title: Query data with InfluxQL
|
||||||
description: >
|
description: >
|
||||||
Use the [InfluxDB 1.x `/query` compatibility endpoint](/influxdb/v2/reference/api/influxdb-1x/query)
|
Use the InfluxDB v1 `/query` compatibility endpoint
|
||||||
to query data in InfluxDB Cloud and InfluxDB OSS 2.4 with **InfluxQL**.
|
to query data in InfluxDB v2 using InfluxQL.
|
||||||
weight: 102
|
weight: 102
|
||||||
influxdb/v2/tags: [influxql, query]
|
influxdb/v2/tags: [influxql, query]
|
||||||
menu:
|
menu:
|
||||||
|
|
|
@ -26,7 +26,7 @@ The URL in the examples depends on the version and location of your InfluxDB {{<
|
||||||
|
|
||||||
{{< code-tabs-wrapper >}}
|
{{< code-tabs-wrapper >}}
|
||||||
{{% code-tabs %}}
|
{{% code-tabs %}}
|
||||||
[Curl](#curl)
|
[cURL](#curl)
|
||||||
[Node.js](#nodejs)
|
[Node.js](#nodejs)
|
||||||
{{% /code-tabs %}}
|
{{% /code-tabs %}}
|
||||||
{{% code-tab-content %}}
|
{{% code-tab-content %}}
|
||||||
|
|
|
@ -10,7 +10,8 @@ menu:
|
||||||
parent: Write data
|
parent: Write data
|
||||||
influxdb/v2/tags: [write, line protocol, errors]
|
influxdb/v2/tags: [write, line protocol, errors]
|
||||||
related:
|
related:
|
||||||
- /influxdb/v2/api/#tag/Write, InfluxDB API /write endpoint
|
- /influxdb/v2/api/v2/#operation/PostLegacyWrite, InfluxDB API /write endpoint
|
||||||
|
- /influxdb/v2/api/v2/#operation/PostWrite, InfluxDB API /api/v2/write endpoint
|
||||||
- /influxdb/v2/reference/internals
|
- /influxdb/v2/reference/internals
|
||||||
- /influxdb/v2/reference/cli/influx/write
|
- /influxdb/v2/reference/cli/influx/write
|
||||||
source: /shared/influxdb-v2/write-data/troubleshoot.md
|
source: /shared/influxdb-v2/write-data/troubleshoot.md
|
||||||
|
|
|
@ -5,13 +5,12 @@ This section guides you through the most commonly used API methods.
|
||||||
|
|
||||||
For detailed documentation on the entire API, see the [InfluxDB v2 API Reference](/influxdb/version/reference/api/#influxdb-v2-api-documentation).
|
For detailed documentation on the entire API, see the [InfluxDB v2 API Reference](/influxdb/version/reference/api/#influxdb-v2-api-documentation).
|
||||||
|
|
||||||
{{% note %}}
|
> [!Note]
|
||||||
If you need to use InfluxDB {{< current-version >}} with **InfluxDB 1.x** API clients and integrations, see the [1.x compatibility API](/influxdb/version/reference/api/#influxdb-v1-compatibility-api-reference-documentation).
|
> If you need to use InfluxDB {{< current-version >}} with **InfluxDB 1.x** API clients and integrations, see the [1.x compatibility API guide](/influxdb/version/api-guide/influxdb-1x).
|
||||||
{{% /note %}}
|
|
||||||
|
|
||||||
## Bootstrap your application
|
## Bootstrap your application
|
||||||
|
|
||||||
With most API requests, you'll need to provide a minimum of your InfluxDB URL and Authorization Token (API Token).
|
With most API requests, you'll need to provide a minimum of your InfluxDB URL and [Authorization Token (API Token)](/influxdb/version/admin/tokens/).
|
||||||
|
|
||||||
[Install InfluxDB OSS v2.x](/influxdb/version/install/) or upgrade to
|
[Install InfluxDB OSS v2.x](/influxdb/version/install/) or upgrade to
|
||||||
an [InfluxDB Cloud account](/influxdb/cloud/sign-up).
|
an [InfluxDB Cloud account](/influxdb/cloud/sign-up).
|
||||||
|
@ -19,11 +18,14 @@ an [InfluxDB Cloud account](/influxdb/cloud/sign-up).
|
||||||
### Authentication
|
### Authentication
|
||||||
|
|
||||||
InfluxDB uses [API tokens](/influxdb/version/admin/tokens/) to authorize API requests.
|
InfluxDB uses [API tokens](/influxdb/version/admin/tokens/) to authorize API requests.
|
||||||
|
InfluxDB filters API requests and response data based on the permissions associated with the token.
|
||||||
|
|
||||||
1. Before exploring the API, use the InfluxDB UI to
|
1. Before exploring the API, use the `influx` CLI or the InfluxDB UI to
|
||||||
[create an initial API token](/influxdb/version/admin/tokens/create-token/) for your application.
|
[create an initial API token](/influxdb/version/admin/tokens/create-token/) for your application.
|
||||||
|
|
||||||
2. Include your API token in an `Authorization: Token YOUR_API_TOKEN` HTTP header with each request.
|
1. Include your API token in an `Authorization: Token API_TOKEN` HTTP header with each request--for example:
|
||||||
|
|
||||||
|
{{% code-placeholders "API_TOKEN" %}}
|
||||||
|
|
||||||
{{< code-tabs-wrapper >}}
|
{{< code-tabs-wrapper >}}
|
||||||
{{% code-tabs %}}
|
{{% code-tabs %}}
|
||||||
|
@ -31,28 +33,94 @@ InfluxDB uses [API tokens](/influxdb/version/admin/tokens/) to authorize API req
|
||||||
[Node.js](#nodejs)
|
[Node.js](#nodejs)
|
||||||
{{% /code-tabs %}}
|
{{% /code-tabs %}}
|
||||||
{{% code-tab-content %}}
|
{{% code-tab-content %}}
|
||||||
```sh
|
```bash
|
||||||
{{% get-shared-text "api/v2.0/auth/oss/token-auth.sh" %}}
|
# Use a token to authorize a GET request to the InfluxDB API.
|
||||||
|
# List buckets in your organization that the token can read.
|
||||||
|
curl -X GET "http://{{< influxdb/host >}}/api/v2/buckets" \
|
||||||
|
--header 'Accept: application/json' \
|
||||||
|
--header 'Authorization: Token API_TOKEN'
|
||||||
```
|
```
|
||||||
{{% /code-tab-content %}}
|
{{% /code-tab-content %}}
|
||||||
{{% code-tab-content %}}
|
{{% code-tab-content %}}
|
||||||
```js
|
```js
|
||||||
{{% get-shared-text "api/v2.0/auth/oss/token-auth.js" %}}
|
/**
|
||||||
|
* Use a token to authorize a GET request to the InfluxDB API.
|
||||||
|
* List buckets in your organization that the token can read.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const https = require('https');
|
||||||
|
|
||||||
|
function listBuckets() {
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
host: '{{< influxdb/host >}}',
|
||||||
|
path: "/api/v2/buckets",
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Token API_TOKEN',
|
||||||
|
'Content-type': 'application/json'
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const request = https.get(options, (response) => {
|
||||||
|
let rawData = '';
|
||||||
|
response.on('data', () => {
|
||||||
|
response.on('data', (chunk) => { rawData += chunk; });
|
||||||
|
})
|
||||||
|
response.on('end', () => {
|
||||||
|
console.log(rawData);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
request.end();
|
||||||
|
}
|
||||||
```
|
```
|
||||||
{{% /code-tab-content %}}
|
{{% /code-tab-content %}}
|
||||||
{{< /code-tabs-wrapper >}}
|
{{< /code-tabs-wrapper >}}
|
||||||
|
|
||||||
Postman is another popular tool for exploring APIs. See how to [send authenticated requests with Postman](/influxdb/version/tools/postman/#send-authenticated-api-requests-with-postman).
|
{{% /code-placeholders %}}
|
||||||
|
|
||||||
|
> [!Note]
|
||||||
|
> Postman is another popular tool for exploring APIs.
|
||||||
|
> See how to [send authenticated requests with Postman](/influxdb/version/tools/postman/#send-authenticated-api-requests-with-postman).
|
||||||
|
|
||||||
## Buckets API
|
## Buckets API
|
||||||
|
|
||||||
Before writing data you'll need to create a Bucket in InfluxDB.
|
Before writing data you'll need to create a bucket in your InfluxDB instance.
|
||||||
[Create a bucket](/influxdb/version/admin/buckets/create-bucket/#create-a-bucket-using-the-influxdb-api) using an HTTP request to the InfluxDB API `/buckets` endpoint.
|
To use the API to create a bucket, send a request to the following endpoint:
|
||||||
|
|
||||||
```sh
|
{{% api-endpoint method="POST" endpoint="/api/v2/buckets" api-ref="/influxdb/version/api/v2/#operation/PostBuckets" %}}
|
||||||
{{% get-shared-text "api/v2.0/buckets/oss/create.sh" %}}
|
|
||||||
|
{{% code-placeholders "API_TOKEN|ORG_ID|BUCKET_NAME|RETENTION_PERIOD_SECONDS" %}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --request POST \
|
||||||
|
"http://localhost:8086/api/v2/buckets" \
|
||||||
|
--header "Authorization: Token API_TOKEN" \
|
||||||
|
--json '{
|
||||||
|
"orgID": "'"ORG_ID"'",
|
||||||
|
"name": "BUCKET_NAME",
|
||||||
|
"retentionRules": [
|
||||||
|
{
|
||||||
|
"type": "expire",
|
||||||
|
"everySeconds": RETENTION_PERIOD_SECONDS,
|
||||||
|
"shardGroupDurationSeconds": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
{{% /code-placeholders %}}
|
||||||
|
|
||||||
|
Replace the following placeholders with your values:
|
||||||
|
|
||||||
|
- {{% code-placeholder-key %}}`API_TOKEN`{{% /code-placeholder-key %}} - your [token](/influxdb/version/admin/tokens/).
|
||||||
|
- {{% code-placeholder-key %}}`ORG_ID`{{% /code-placeholder-key %}} - the ID of the [organization](/influxdb/version/admin/organizations/) that owns the bucket.
|
||||||
|
- {{% code-placeholder-key %}}`BUCKET_NAME`{{% /code-placeholder-key %}} - the name of the [bucket](/influxdb/version/admin/buckets/) to create.
|
||||||
|
- Optional: {{% code-placeholder-key %}}`RETENTION_PERIOD_SECONDS`{{% /code-placeholder-key %}} - the [retention period](/influxdb/version/reference/glossary/#retention-period) (in number of seconds) to retain data in the bucket. Default is `0` (infinite retention).
|
||||||
|
- For example, `31536000` (1 year) or `604800` (7 days).
|
||||||
|
|
||||||
|
For more information, see [Create a bucket](/influxdb/version/admin/buckets/create-bucket/#create-a-bucket-using-the-influxdb-api).
|
||||||
|
|
||||||
## Write API
|
## Write API
|
||||||
|
|
||||||
[Write data to InfluxDB](/influxdb/version/write-data/developer-tools/api/) using an HTTP request to the InfluxDB API `/api/v2/write` endpoint.
|
[Write data to InfluxDB](/influxdb/version/write-data/developer-tools/api/) using an HTTP request to the InfluxDB API `/api/v2/write` endpoint.
|
||||||
|
|
|
@ -7,7 +7,7 @@ InfluxDB 1.x client libraries and third-party integrations like [Grafana](https:
|
||||||
## Authentication
|
## Authentication
|
||||||
|
|
||||||
InfluxDB 1.x compatibility endpoints require all query and write requests to be authenticated with an
|
InfluxDB 1.x compatibility endpoints require all query and write requests to be authenticated with an
|
||||||
[API token](/influxdb/version/admin/tokens/) or 1.x-compatible
|
[API token](/influxdb/version/admin/tokens/) or v1-compatible
|
||||||
credentials.
|
credentials.
|
||||||
|
|
||||||
* [Authenticate with the Token scheme](#authenticate-with-the-token-scheme)
|
* [Authenticate with the Token scheme](#authenticate-with-the-token-scheme)
|
||||||
|
@ -67,12 +67,12 @@ Username and password schemes require the following credentials:
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
#### Password or Token
|
#### Password or Token
|
||||||
|
|
||||||
If you have [set a password](/influxdb/version/install/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations) for the 1.x-compatible username, provide the 1.x-compatible password.
|
If you have [set a password](/influxdb/version/install/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations) for the v1-compatible username, provide the v1-compatible password.
|
||||||
If you haven't set a password for the 1.x-compatible username, provide the InfluxDB [authentication token](/influxdb/version/admin/tokens/) as the password.
|
If you haven't set a password for the v1-compatible username, provide the InfluxDB [authentication token](/influxdb/version/admin/tokens/) as the password.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
For more information, see how to create and manage
|
For more information, see how to create and manage
|
||||||
[1.x-compatible authorizations](/influxdb/version/install/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations)
|
[v1-compatible authorizations](/influxdb/version/install/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations)
|
||||||
when manually upgrading from InfluxDB v1 to v2.
|
when manually upgrading from InfluxDB v1 to v2.
|
||||||
|
|
||||||
{{% /show-in %}}
|
{{% /show-in %}}
|
||||||
|
|
|
@ -496,7 +496,7 @@ To query data from InfluxDB using InfluxQL and the InfluxDB HTTP API, send a req
|
||||||
to the InfluxDB API [`/query` 1.X compatibility endpoint](/influxdb/version/reference/api/influxdb-1x/query/)
|
to the InfluxDB API [`/query` 1.X compatibility endpoint](/influxdb/version/reference/api/influxdb-1x/query/)
|
||||||
using the `POST` request method.
|
using the `POST` request method.
|
||||||
|
|
||||||
{{< api-endpoint endpoint="http://localhost:8086/query" method="post" api-ref="/influxdb/version/api/v1-compatibility/#operation/PostQueryV1" >}}
|
{{< api-endpoint endpoint="http://localhost:8086/query" method="post" api-ref="/influxdb/version/api/v1/#operation/PostQueryV1" >}}
|
||||||
|
|
||||||
Include the following with your request:
|
Include the following with your request:
|
||||||
|
|
||||||
|
|
|
@ -2,63 +2,71 @@
|
||||||
The [InfluxDB v2 API](/influxdb/version/reference/api) provides a programmatic interface for all interactions with InfluxDB.
|
The [InfluxDB v2 API](/influxdb/version/reference/api) provides a programmatic interface for all interactions with InfluxDB.
|
||||||
To query InfluxDB {{< current-version >}}, do one of the following:
|
To query InfluxDB {{< current-version >}}, do one of the following:
|
||||||
|
|
||||||
- Send a Flux query request to the [`/api/v2/query`](/influxdb/version/api/#operation/PostQueryAnalyze) endpoint.
|
- [Send a Flux query request](#send-a-flux-query-request)
|
||||||
- Send an InfluxQL query request to the [/query 1.x compatibility API](/influxdb/version/reference/api/influxdb-1x/query/).
|
- [Send an InfluxQL query request](#send-an-influxql-query-request)
|
||||||
|
|
||||||
|
## Send a Flux query request
|
||||||
|
|
||||||
|
Send a Flux query request to the following endpoint:
|
||||||
|
|
||||||
|
{{% api-endpoint method="POST" endpoint="/api/v2/query" api-ref="/influxdb/version/api/#operation/PostQueryAnalyze" %}}
|
||||||
|
|
||||||
In your request, set the following:
|
In your request, set the following:
|
||||||
|
|
||||||
- Your organization via the `org` or `orgID` URL parameters.
|
- Your organization via the `org` or `orgID` URL parameters
|
||||||
- `Authorization` header to `Token ` + your API token.
|
- Headers:
|
||||||
- `Accept` header to `application/csv`.
|
- `Authorization: Token <API_TOKEN>`
|
||||||
- `Content-type` header to `application/vnd.flux` (Flux only) or `application/json` (Flux or InfluxQL).
|
- `Accept: application/csv`
|
||||||
- Query in Flux or InfluxQL with the request's raw data.
|
- `Content-type: application/vnd.flux`
|
||||||
|
- Your Flux query text in the request body
|
||||||
|
|
||||||
{{% note %}}
|
> [!Note]
|
||||||
#### Use gzip to compress the query response
|
> #### Use gzip to compress a large query response
|
||||||
|
>
|
||||||
To compress the query response, set the `Accept-Encoding` header to `gzip`.
|
> To compress the query response, set the `Accept-Encoding` header to `gzip`.
|
||||||
This saves network bandwidth, but increases server-side load.
|
> This saves network bandwidth, but increases server-side load.
|
||||||
|
>
|
||||||
We recommend only using gzip compression on responses that are larger than 1.4 KB.
|
> We recommend only using gzip compression on responses that are larger than 1.4 KB.
|
||||||
If the response is smaller than 1.4 KB, gzip encoding will always return a 1.4 KB
|
> If the response is smaller than 1.4 KB, gzip encoding will always return a 1.4 KB
|
||||||
response, despite the uncompressed response size.
|
> response, despite the uncompressed response size.
|
||||||
1500 bytes (~1.4 KB) is the maximum transmission unit (MTU) size for the public
|
> 1500 bytes (~1.4 KB) is the maximum transmission unit (MTU) size for the public
|
||||||
network and is the largest packet size allowed at the network layer.
|
> network and is the largest packet size allowed at the network layer.
|
||||||
{{% /note %}}
|
|
||||||
|
|
||||||
#### Flux - Example query request
|
#### Flux - Example query request
|
||||||
|
|
||||||
Below is an example `curl` request that sends a Flux query to InfluxDB {{< current-version >}}:
|
The following example shows how to use cURL to send a Flux query to InfluxDB {{< current-version >}}:
|
||||||
|
|
||||||
|
{{% code-placeholders "ORG_ID|API_TOKEN|BUCKET_NAME" %}}
|
||||||
|
|
||||||
{{< code-tabs-wrapper >}}
|
{{< code-tabs-wrapper >}}
|
||||||
{{% code-tabs %}}
|
{{% code-tabs %}}
|
||||||
[Without compression](#)
|
[Without compression](#)
|
||||||
[With compression](#)
|
[With compression](#)
|
||||||
{{% /code-tabs %}}
|
{{% /code-tabs %}}
|
||||||
|
|
||||||
{{% code-tab-content %}}
|
{{% code-tab-content %}}
|
||||||
```bash
|
```bash
|
||||||
curl --request POST \
|
curl \
|
||||||
http://localhost:8086/api/v2/query?orgID=INFLUX_ORG_ID \
|
--request POST \
|
||||||
--header 'Authorization: Token INFLUX_TOKEN' \
|
http://{{< influxdb/host >}}/api/v2/query?orgID=ORG_ID \
|
||||||
|
--header 'Authorization: Token API_TOKEN' \
|
||||||
--header 'Accept: application/csv' \
|
--header 'Accept: application/csv' \
|
||||||
--header 'Content-type: application/vnd.flux' \
|
--header 'Content-type: application/vnd.flux' \
|
||||||
--data 'from(bucket:"example-bucket")
|
--data 'from(bucket:"BUCKET_NAME")
|
||||||
|> range(start: -12h)
|
|> range(start: -12h)
|
||||||
|> filter(fn: (r) => r._measurement == "example-measurement")
|
|> filter(fn: (r) => r._measurement == "example-measurement")
|
||||||
|> aggregateWindow(every: 1h, fn: mean)'
|
|> aggregateWindow(every: 1h, fn: mean)'
|
||||||
```
|
```
|
||||||
{{% /code-tab-content %}}
|
{{% /code-tab-content %}}
|
||||||
|
|
||||||
{{% code-tab-content %}}
|
{{% code-tab-content %}}
|
||||||
```bash
|
```bash
|
||||||
curl --request POST \
|
curl \
|
||||||
http://localhost:8086/api/v2/query?orgID=INFLUX_ORG_ID \
|
--request POST \
|
||||||
--header 'Authorization: Token INFLUX_TOKEN' \
|
http://{{< influxdb/host >}}/api/v2/query?orgID=ORG_ID \
|
||||||
|
--header 'Authorization: Token API_TOKEN' \
|
||||||
--header 'Accept: application/csv' \
|
--header 'Accept: application/csv' \
|
||||||
--header 'Content-type: application/vnd.flux' \
|
--header 'Content-type: application/vnd.flux' \
|
||||||
--header 'Accept-Encoding: gzip' \
|
--header 'Accept-Encoding: gzip' \
|
||||||
--data 'from(bucket:"example-bucket")
|
--data 'from(bucket:"BUCKET_NAME")
|
||||||
|> range(start: -12h)
|
|> range(start: -12h)
|
||||||
|> filter(fn: (r) => r._measurement == "example-measurement")
|
|> filter(fn: (r) => r._measurement == "example-measurement")
|
||||||
|> aggregateWindow(every: 1h, fn: mean)'
|
|> aggregateWindow(every: 1h, fn: mean)'
|
||||||
|
@ -66,9 +74,82 @@ curl --request POST \
|
||||||
{{% /code-tab-content %}}
|
{{% /code-tab-content %}}
|
||||||
{{< /code-tabs-wrapper >}}
|
{{< /code-tabs-wrapper >}}
|
||||||
|
|
||||||
|
{{% /code-placeholders %}}
|
||||||
|
|
||||||
|
Replace the following with your values:
|
||||||
|
|
||||||
|
- {{% code-placeholder-key %}}`ORG_ID`{{% /code-placeholder-key %}} - the ID of the [organization](/influxdb/version/admin/organizations/) that owns the bucket.
|
||||||
|
- {{% code-placeholder-key %}}`API_TOKEN`{{% /code-placeholder-key %}} - your [token](/influxdb/version/admin/tokens/).
|
||||||
|
- {{% code-placeholder-key %}}`BUCKET_NAME`{{% /code-placeholder-key %}} - the name of the [bucket](/influxdb/version/admin/buckets/) to query.
|
||||||
|
|
||||||
|
## Send an InfluxQL query request
|
||||||
|
|
||||||
|
To query InfluxDB {{< current-version >}} using the [InfluxQL query language](/influxdb/v2/reference/syntax/influxql/), send a request to the v1-compatible API endpoint:
|
||||||
|
|
||||||
|
{{% api-endpoint method="GET" endpoint="/query" api-ref="/influxdb/v2/api/v2/#operation/GetLegacyQuery" %}}
|
||||||
|
|
||||||
|
{{% api-endpoint method="POST" endpoint="/query" api-ref="/influxdb/v2/api/v2/#operation/PostQueryV1" %}}
|
||||||
|
|
||||||
|
In your request, set the following:
|
||||||
|
|
||||||
|
- [1.x-compatible or 2.x authentication](/influxdb/v2/api-guide/influxdb-1x/#authentication) credentials
|
||||||
|
- Headers:
|
||||||
|
- `Accept: application/csv` or `Accept: application/json`
|
||||||
|
- `Content-type: application/vnd.influxql`
|
||||||
|
- The database and retention policy mapped to the bucket you want to query
|
||||||
|
- Your InfluxQL query text
|
||||||
|
|
||||||
|
> [!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/query-data/influxql/dbrp/#create-dbrp-mappings)
|
||||||
|
> to query that bucket with the `/query` compatibility API.
|
||||||
|
> Use the `db` and `rp` query parameters to specify the database and retention policy
|
||||||
|
> for the bucket you want to query.
|
||||||
|
|
||||||
#### InfluxQL - Example query request
|
#### InfluxQL - Example query request
|
||||||
|
|
||||||
Below is an example `curl` request that sends an InfluxQL query to InfluxDB {{< current-version >}}:
|
The following example shows how to use cURL to send an InfluxQL query to InfluxDB {{< current-version >}} using v1-compatible authentication:
|
||||||
|
|
||||||
|
{{% code-placeholders "API_TOKEN|BUCKET_NAME" %}}
|
||||||
|
|
||||||
|
{{< code-tabs-wrapper >}}
|
||||||
|
{{% code-tabs %}}
|
||||||
|
[HTTP POST](#)
|
||||||
|
[HTTP GET](#)
|
||||||
|
{{% /code-tabs %}}
|
||||||
|
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1.x compatible POST request using Basic authentication and InfluxQL
|
||||||
|
curl --request POST \
|
||||||
|
"http://{{< influxdb/host >}}/query?db=BUCKET_NAME&p=API_TOKEN&u=ignored" \
|
||||||
|
--header "Content-type: application/vnd.influxql" \
|
||||||
|
--data "SELECT * FROM home WHERE time > now() - 1h"
|
||||||
|
```
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1.x compatible GET request using Basic authentication and InfluxQL
|
||||||
|
curl --get "http://{{< influxdb/host >}}/query" \
|
||||||
|
--header "Accept: application/json" \
|
||||||
|
--data-urlencode "q=SELECT * FROM home WHERE time > now() - 1h" \
|
||||||
|
--data-urlencode "db=BUCKET_NAME" \
|
||||||
|
--data-urlencode "u=ignored" \
|
||||||
|
--data-urlencode "p=API_TOKEN"
|
||||||
|
```
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{< /code-tabs-wrapper >}}
|
||||||
|
|
||||||
|
{{% /code-placeholders %}}
|
||||||
|
|
||||||
|
Replace the following with your values:
|
||||||
|
|
||||||
|
- {{% code-placeholder-key %}}`API_TOKEN`{{% /code-placeholder-key %}} - your [token](/influxdb/version/admin/tokens/).
|
||||||
|
- {{% code-placeholder-key %}}`BUCKET_NAME`{{% /code-placeholder-key %}} - the name of the [bucket](/influxdb/version/admin/buckets/) to query.
|
||||||
|
|
||||||
|
{{% code-placeholders "ORG_ID|API_TOKEN|BUCKET_NAME" %}}
|
||||||
|
|
||||||
{{< code-tabs-wrapper >}}
|
{{< code-tabs-wrapper >}}
|
||||||
{{% code-tabs %}}
|
{{% code-tabs %}}
|
||||||
|
@ -78,24 +159,35 @@ Below is an example `curl` request that sends an InfluxQL query to InfluxDB {{<
|
||||||
|
|
||||||
{{% code-tab-content %}}
|
{{% code-tab-content %}}
|
||||||
```bash
|
```bash
|
||||||
curl --request -G http://localhost:8086/query?orgID=INFLUX_ORG_ID&database=MyDB&retention_policy=MyRP \
|
curl --get "http://{{< influxdb/host >}}/query" \
|
||||||
--header 'Authorization: Token INFLUX_TOKEN' \
|
|
||||||
--header 'Accept: application/csv' \
|
--header 'Accept: application/csv' \
|
||||||
--header 'Content-type: application/json' \
|
--header 'Content-type: application/json' \
|
||||||
|
--data-urlencode "db=BUCKET_NAME" \
|
||||||
|
--data-urlencode "p=API_TOKEN" \
|
||||||
|
--data-urlencode "u=ignored" \
|
||||||
--data-urlencode "q=SELECT used_percent FROM example-db.example-rp.example-measurement WHERE host=host1"
|
--data-urlencode "q=SELECT used_percent FROM example-db.example-rp.example-measurement WHERE host=host1"
|
||||||
```
|
```
|
||||||
{{% /code-tab-content %}}
|
{{% /code-tab-content %}}
|
||||||
|
|
||||||
{{% code-tab-content %}}
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl --request -G http://localhost:8086/query?orgID=INFLUX_ORG_ID&database=MyDB&retention_policy=MyRP \
|
curl --get "http://{{< influxdb/host >}}/query" \
|
||||||
--header 'Authorization: Token INFLUX_TOKEN' \
|
|
||||||
--header 'Accept: application/csv' \
|
--header 'Accept: application/csv' \
|
||||||
--header 'Content-type: application/json' \
|
--header 'Content-type: application/json' \
|
||||||
--header 'Accept-Encoding: gzip' \
|
--header 'Accept-Encoding: gzip' \
|
||||||
|
--data-urlencode "db=BUCKET_NAME" \
|
||||||
|
--data-urlencode "p=API_TOKEN" \
|
||||||
|
--data-urlencode "u=ignored" \
|
||||||
--data-urlencode "q=SELECT used_percent FROM example-db.example-rp.example-measurement WHERE host=host1"
|
--data-urlencode "q=SELECT used_percent FROM example-db.example-rp.example-measurement WHERE host=host1"
|
||||||
```
|
```
|
||||||
{{% /code-tab-content %}}
|
{{% /code-tab-content %}}
|
||||||
{{< /code-tabs-wrapper >}}
|
{{< /code-tabs-wrapper >}}
|
||||||
|
|
||||||
|
{{% /code-placeholders %}}
|
||||||
|
|
||||||
|
Replace the following with your values:
|
||||||
|
|
||||||
|
- {{% code-placeholder-key %}}`API_TOKEN`{{% /code-placeholder-key %}} - your [token](/influxdb/version/admin/tokens/).
|
||||||
|
- {{% code-placeholder-key %}}`BUCKET_NAME`{{% /code-placeholder-key %}} - the name of the [bucket](/influxdb/version/admin/buckets/) to query.
|
||||||
|
|
||||||
InfluxDB returns the query results in [annotated CSV](/influxdb/version/reference/syntax/annotated-csv/).
|
InfluxDB returns the query results in [annotated CSV](/influxdb/version/reference/syntax/annotated-csv/).
|
||||||
|
|
|
@ -191,7 +191,7 @@ InfluxQL requires single quotes around tag values in the `WHERE` clause.
|
||||||
|
|
||||||
{{% /expand %}}
|
{{% /expand %}}
|
||||||
|
|
||||||
{{% expand "Select data with specific field key-values and tag key-valuest" %}}
|
{{% expand "Select data with specific field key-values and tag key-values" %}}
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT "water_level" FROM "h2o_feet" WHERE "location" <> 'santa_monica' AND (water_level < -0.59 OR water_level > 9.95)
|
SELECT "water_level" FROM "h2o_feet" WHERE "location" <> 'santa_monica' AND (water_level < -0.59 OR water_level > 9.95)
|
||||||
|
|
|
@ -6,7 +6,7 @@ InfluxDB {{< current-version >}} uses [API tokens](/influxdb/version/admin/token
|
||||||
The [1.x compatibility API](/influxdb/version/reference/api/influxdb-1x/) lets clients authenticate with InfluxDB {{< current-version >}} using the InfluxDB 1.x convention of username and password.
|
The [1.x compatibility API](/influxdb/version/reference/api/influxdb-1x/) lets clients authenticate with InfluxDB {{< current-version >}} using the InfluxDB 1.x convention of username and password.
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
1.x-compatible authorizations are separate from the credentials used to log
|
v1-compatible authorizations are separate from the credentials used to log
|
||||||
into the InfluxDB user interface.
|
into the InfluxDB user interface.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
|
|
|
@ -664,8 +664,8 @@ from(bucket: "example-bucket")
|
||||||
{{% /show-in %}}
|
{{% /show-in %}}
|
||||||
|
|
||||||
Using InfluxQL with InfluxDB {{< current-version >}} is made possible by the
|
Using InfluxQL with InfluxDB {{< current-version >}} is made possible by the
|
||||||
[1.x compatibility API](/influxdb/version/reference/api/influxdb-1x/) which replicates
|
[v1 compatibility API](/influxdb/version/reference/api/influxdb-1x/) which replicates
|
||||||
the `/query` endpoint from InfluxDB 1.x. This allows all InfluxDB 1.x-compatible
|
the `/query` endpoint from InfluxDB 1.x. This allows all InfluxDB v1-compatible
|
||||||
clients to work with InfluxDB {{< current-version >}}. However, InfluxQL relies
|
clients to work with InfluxDB {{< current-version >}}. However, InfluxQL relies
|
||||||
on a database and retention policy data model doesn't exist in InfluxDB
|
on a database and retention policy data model doesn't exist in InfluxDB
|
||||||
{{< current-version >}}, but has been replaced by [buckets](/influxdb/version/reference/glossary/#bucket).
|
{{< current-version >}}, but has been replaced by [buckets](/influxdb/version/reference/glossary/#bucket).
|
||||||
|
|
Loading…
Reference in New Issue