added gzip compression to query guide, resolves #384
parent
fbbc5ddd88
commit
3a6d855fa4
content/v2.0/query-data
|
@ -60,35 +60,50 @@ In your request, set the following:
|
|||
|
||||
- Your organization via the `org` or `orgID` URL parameters.
|
||||
- `Authorization` header to `Token ` + your authentication token.
|
||||
- `accept` header to `application/csv`.
|
||||
- `content-type` header to `application/vnd.flux`.
|
||||
- `Accept` header to `application/csv`.
|
||||
- `Content-type` header to `application/vnd.flux`.
|
||||
- Your plain text query as the request's raw data.
|
||||
|
||||
This lets you POST the Flux query in plain text and receive the annotated CSV response.
|
||||
InfluxDB returns the query results in [annotated CSV](/v2.0/reference/annotated-csv/).
|
||||
|
||||
{{% note %}}
|
||||
#### Use gzip to compress the query response
|
||||
To compress the query response, set the `Accept-Encoding` header to `gzip`.
|
||||
This saves network bandwidth, but increases server-side load.
|
||||
{{% /note %}}
|
||||
|
||||
Below is an example `curl` command that queries InfluxDB:
|
||||
|
||||
{{< code-tabs-wrapper >}}
|
||||
{{% code-tabs %}}
|
||||
[Multi-line](#)
|
||||
[Single-line](#)
|
||||
[Without compression](#)
|
||||
[With compression](#)
|
||||
{{% /code-tabs %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
```bash
|
||||
curl http://localhost:9999/api/v2/query?org=my-org -XPOST -sS \
|
||||
-H 'Authorization: Token YOURAUTHTOKEN' \
|
||||
-H 'accept:application/csv' \
|
||||
-H 'content-type:application/vnd.flux' \
|
||||
-d 'from(bucket:“test”)
|
||||
|> range(start:-1000h)
|
||||
|> group(columns:[“_measurement”], mode:“by”)
|
||||
|> sum()'
|
||||
-H 'Authorization: Token YOURAUTHTOKEN' \
|
||||
-H 'Accept: application/csv' \
|
||||
-H 'Content-type: application/vnd.flux' \
|
||||
-d 'from(bucket:“test”)
|
||||
|> range(start:-1000h)
|
||||
|> group(columns:[“_measurement”], mode:“by”)
|
||||
|> sum()'
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
```bash
|
||||
curl http://localhost:9999/api/v2/query?org=my-org -XPOST -sS -H 'Authorization: Token TOKENSTRINGHERE' -H 'accept:application/csv' -H 'content-type:application/vnd.flux' -d 'from(bucket:“test”) |> range(start:-1000h) |> group(columns:[“_measurement”], mode:“by”) |> sum()'
|
||||
curl http://localhost:9999/api/v2/query?org=my-org -XPOST -sS \
|
||||
-H 'Authorization: Token YOURAUTHTOKEN' \
|
||||
-H 'Accept: application/csv' \
|
||||
-H 'Content-type: application/vnd.flux' \
|
||||
-H 'Accept-Encoding: gzip' \
|
||||
-d 'from(bucket:“test”)
|
||||
|> range(start:-1000h)
|
||||
|> group(columns:[“_measurement”], mode:“by”)
|
||||
|> sum()'
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
|
|
Loading…
Reference in New Issue