docs-v2/content/v2.0/query-data/influxql.md

2.8 KiB

title description weight v2.0/tags menu products related
Query data with InfluxQL Use the [InfluxDB 1.x `/query` compatibility endpoint](/v2.0/reference/api/influxdb-1x/query) to query data in InfluxDB 2.0 with **InfluxQL**. 102
influxql
query
v2_0
name parent
Query with InfluxQL Query data
cloud
/v2.0/reference/api/influxdb-1x/
/v2.0/reference/api/influxdb-1x/query
/v2.0/reference/api/influxdb-1x/dbrp

Use the InfluxDB 1.x /query compatibility endpoint to query data in InfluxDB 2.0 with InfluxQL. The InfluxDB 1.x compatibility API supports all InfluxDB 1.x client libraries and integrations in InfluxDB 2.0.

Provide the following:

{{% note %}} URL-encode the InfluxQL query to ensure it's formatted correctly when submitted to InfluxDB. {{% /note %}}

curl -G https://cloud2.influxdata.com/query?db=db&rp=rp \
  -H "Authorization: Token YourAuthToken" \
  --data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"

By default, the /query compatibility endpoint returns results in JSON. To return results as CSV, include the Accept: application/csv header.

Database and retention policy mapping

InfluxDB 2.0 combines the 1.x concept of databases and retention policies into buckets. To support InfluxDB 1.x query and write patterns in InfluxDB 2.0, databases and retention policies are mapped to buckets using the database and retention policy (DBRP) mapping service. See DBRP mapping for more information.

InfluxQL support

InfluxQL in InfluxDB 2.0 supports read-only queries.

{{< flex >}} {{< flex-content >}} {{% note %}}

Supported InfluxQL queries
  • SELECT (read-only)
  • SHOW DATABASES
  • SHOW MEASUREMENTS
  • SHOW TAG KEYS
  • SHOW TAG VALUES
  • SHOW FIELD KEYS {{% /note %}} {{< /flex-content >}} {{< flex-content >}} {{% warn %}}
Unsupported InfluxQL queries
  • SELECT INTO
  • ALTER
  • CREATE
  • DELETE
  • DROP
  • GRANT
  • KILL
  • REVOKE {{% /warn %}} {{< /flex-content >}} {{< /flex >}}

Use the InfluxDB 2.0 UI, CLI, and API to perform the following actions: