From 3a6d855fa43bf8d48f37623e38b75f1d51883d2d Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 19 Sep 2019 09:31:28 -0600 Subject: [PATCH] added gzip compression to query guide, resolves #384 --- content/v2.0/query-data/execute-queries.md | 41 +++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/content/v2.0/query-data/execute-queries.md b/content/v2.0/query-data/execute-queries.md index 462db6f40..d001a9a7e 100644 --- a/content/v2.0/query-data/execute-queries.md +++ b/content/v2.0/query-data/execute-queries.md @@ -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 >}}