Standardize formatting of curl API examples (#1714)
Standardize formatting of curl API examplespull/1721/head
parent
cb3cc221fe
commit
f2e458ea96
|
@ -81,10 +81,10 @@ Below is an example `curl` command that queries InfluxDB:
|
|||
{{% code-tab-content %}}
|
||||
```bash
|
||||
curl http://localhost:8086/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:"example-bucket")
|
||||
--header 'Authorization: Token YOURAUTHTOKEN' \
|
||||
--header 'Accept: application/csv' \
|
||||
--header 'Content-type: application/vnd.flux' \
|
||||
--data 'from(bucket:"example-bucket")
|
||||
|> range(start: -12h)
|
||||
|> filter(fn: (r) => r._measurement == "example-measurement")
|
||||
|> aggregateWindow(every: 1h, fn: mean)'
|
||||
|
@ -93,12 +93,12 @@ curl http://localhost:8086/api/v2/query?org=my-org -XPOST -sS \
|
|||
|
||||
{{% code-tab-content %}}
|
||||
```bash
|
||||
curl http://localhost:8086/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:"example-bucket")
|
||||
curl --request POST http://localhost:8086/api/v2/query?org=my-org \
|
||||
--header 'Authorization: Token YOURAUTHTOKEN' \
|
||||
--header 'Accept: application/csv' \
|
||||
--header 'Content-type: application/vnd.flux' \
|
||||
--header 'Accept-Encoding: gzip' \
|
||||
--data 'from(bucket:"example-bucket")
|
||||
|> range(start: -12h)
|
||||
|> filter(fn: (r) => r._measurement == "example-measurement")
|
||||
|> aggregateWindow(every: 1h, fn: mean)'
|
||||
|
|
|
@ -75,7 +75,8 @@ Use `curl` and the `influx write` command to write bird migration line protocol
|
|||
Replace `example-bucket` with your destination bucket:
|
||||
|
||||
```sh
|
||||
curl https://raw.githubusercontent.com/influxdata/influxdb2-sample-data/master/bird-migration-data/bird-migration.line --output ./tmp-data
|
||||
curl https://raw.githubusercontent.com/influxdata/influxdb2-sample-data/master/bird-migration-data/bird-migration.line \
|
||||
--output ./tmp-data
|
||||
influx write -b example-bucket @./tmp-data
|
||||
rm -f ./tmp-data
|
||||
```
|
||||
|
|
|
@ -233,10 +233,10 @@ to store your database credentials as secrets.
|
|||
{{% /tabs %}}
|
||||
{{% tab-content %}}
|
||||
```sh
|
||||
curl -X PATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \
|
||||
-H 'Authorization: Token YOURAUTHTOKEN' \
|
||||
-H 'Content-type: application/json' \
|
||||
-d '{
|
||||
curl --request PATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \
|
||||
--header 'Authorization: Token YOURAUTHTOKEN' \
|
||||
--header 'Content-type: application/json' \
|
||||
--data '{
|
||||
"POSTGRES_HOST": "http://example.com",
|
||||
"POSTGRES_USER": "example-username",
|
||||
"POSTGRES_PASS": "example-password"
|
||||
|
|
|
@ -36,10 +36,10 @@ Verify the buckets that you want to query are mapped to a database and retention
|
|||
- To find a specific bucket (`bucket_id`), database (`database`), retention policy (`retention_policy`), or mapping ID (`id`), include the parameter in your request.
|
||||
|
||||
```sh
|
||||
curl -GET https://cloud2.influxdata.com/api/v2/dbrps \
|
||||
-H "Authorization: Token YourAuthToken" \
|
||||
-H 'Content-type: application/json' \
|
||||
-d '{
|
||||
curl --request GET https://cloud2.influxdata.com/api/v2/dbrps \
|
||||
--header "Authorization: Token YourAuthToken" \
|
||||
--header 'Content-type: application/json' \
|
||||
--data '{
|
||||
"bucket_id": "12ab34cd56ef",
|
||||
"database": "example-db",
|
||||
"id": "example-mapping-id"
|
||||
|
@ -62,10 +62,10 @@ To map an unmapped bucket to a database and retention policy, use the [`POST /db
|
|||
- database and retention policy to map to bucket (`database` and `retention_policy`)
|
||||
|
||||
```sh
|
||||
curl -XPOST https://cloud2.influxdata.com/api/v2/dbrps \
|
||||
-H "Authorization: Token YourAuthToken" \
|
||||
-H 'Content-type: application/json' \
|
||||
-d '{
|
||||
curl --request POST https://cloud2.influxdata.com/api/v2/dbrps \
|
||||
--header "Authorization: Token YourAuthToken" \
|
||||
--header 'Content-type: application/json' \
|
||||
--data '{
|
||||
"bucket_id": "12ab34cd56ef",
|
||||
"database": "example-db",
|
||||
"default": true
|
||||
|
@ -95,8 +95,8 @@ To query a mapped bucket with InfluxQL, use the `/query` 1.x compatibility endpo
|
|||
{{% /note %}}
|
||||
|
||||
```sh
|
||||
curl -G https://cloud2.influxdata.com/query?database=MyDB&retention_policy=MyRP \
|
||||
-H "Authorization: Token YourAuthToken" \
|
||||
curl --request GET https://cloud2.influxdata.com/query?database=MyDB&retention_policy=MyRP \
|
||||
--header "Authorization: Token YourAuthToken" \
|
||||
--data-urlencode "q=SELECT used_percent FROM example-db.example-rp.example-measurement WHERE host=host1"
|
||||
```
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ Include your authentication token as an `Authorization` header in each request.
|
|||
|
||||
```sh
|
||||
curl --request POST \
|
||||
--url http://localhost:8086/api/v2/write?org=my-org&bucket=example-bucket \
|
||||
--header 'Authorization: Token YOURAUTHTOKEN'
|
||||
http://localhost:8086/api/v2/write?org=my-org&bucket=example-bucket \
|
||||
--header "Authorization: Token YOURAUTHTOKEN"
|
||||
```
|
||||
|
||||
## View InfluxDB v2 API Documentation
|
||||
|
|
|
@ -81,16 +81,16 @@ The following precisions are available:
|
|||
|
||||
##### Query using basic authentication
|
||||
```sh
|
||||
curl -G https://cloud2.influxdata.com/query \
|
||||
-u username:YourAuthToken \
|
||||
curl --request GET https://cloud2.influxdata.com/query \
|
||||
--user "username:YourAuthToken" \
|
||||
--data-urlencode "db=mydb" \
|
||||
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
|
||||
```
|
||||
|
||||
##### Query a non-default retention policy
|
||||
```sh
|
||||
curl -G https://cloud2.influxdata.com/query \
|
||||
-H "Authorization: Basic username:YourAuthToken" \
|
||||
curl --request GET https://cloud2.influxdata.com/query \
|
||||
--header "Authorization: Basic username:YourAuthToken" \
|
||||
--data-urlencode "db=mydb" \
|
||||
--data-urlencode "rp=customrp" \
|
||||
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
|
||||
|
@ -98,27 +98,27 @@ curl -G https://cloud2.influxdata.com/query \
|
|||
|
||||
##### Execute multiple queries
|
||||
```sh
|
||||
curl -G https://cloud2.influxdata.com/query \
|
||||
-H "Authorization: Token YourAuthToken" \
|
||||
curl --request GET https://cloud2.influxdata.com/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 -G https://cloud2.influxdata.com/query \
|
||||
-H "Authorization: Token YourAuthToken" \
|
||||
curl --request GET https://cloud2.influxdata.com/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 "q=SELECT used_percent FROM mem WHERE host=host1" \
|
||||
--data-urlencode "epoch=ms"
|
||||
```
|
||||
|
||||
##### Use curl to execute InfluxQL queries from a file
|
||||
```sh
|
||||
curl -G https://cloud2.influxdata.com/query \
|
||||
-H "Authorization: Token YourAuthToken" \
|
||||
curl --request GET https://cloud2.influxdata.com/query \
|
||||
--header "Authorization: Token YourAuthToken" \
|
||||
--data-urlencode "db=mydb" \
|
||||
-F "q=@path/to/influxql.txt"
|
||||
-F "async=true"
|
||||
--form "q=@path/to/influxql.txt" \
|
||||
--form "async=true"
|
||||
```
|
||||
|
|
|
@ -71,22 +71,23 @@ The following precisions are available:
|
|||
|
||||
##### Write data using basic authentication
|
||||
```sh
|
||||
curl -XPOST https://cloud2.influxdata.com/write?db=mydb \
|
||||
-H "Authorization: Basic username:YourAuthToken" \
|
||||
curl --request POST https://cloud2.influxdata.com/write?db=mydb \
|
||||
--header "Authorization: Basic username:YourAuthToken" \
|
||||
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
|
||||
```
|
||||
|
||||
##### Write data to a non-default retention policy
|
||||
```sh
|
||||
curl -XPOST https://cloud2.influxdata.com/write?db=mydb&rp=customrp \
|
||||
-H "Authorization: Basic username:YourAuthToken" \
|
||||
curl --request POST https://cloud2.influxdata.com/write?db=mydb&rp=customrp \
|
||||
--header "Authorization: Basic" \
|
||||
--header "username:YourAuthToken" \
|
||||
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
|
||||
```
|
||||
|
||||
##### Write multiple lines of line protocol
|
||||
```sh
|
||||
curl -XPOST https://cloud2.influxdata.com/write?db=mydb \
|
||||
-H "Authorization: Token YourAuthToken" \
|
||||
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"
|
||||
|
@ -94,14 +95,14 @@ measurement,host=host3 field1=5i,field2=6.8 1577836800000000000"
|
|||
|
||||
##### Write data with millisecond Unix timestamps
|
||||
```sh
|
||||
curl -XPOST https://cloud2.influxdata.com/write?db=mydb&precision=ms \
|
||||
-H "Authorization: Token YourAuthToken" \
|
||||
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 -XPOST https://cloud2.influxdata.com/write?db=mydb \
|
||||
-H "Authorization: Token YourAuthToken" \
|
||||
curl --request POST https://cloud2.influxdata.com/write?db=mydb \
|
||||
--header "Authorization: Token YourAuthToken" \
|
||||
--data-binary @path/to/line-protocol.txt
|
||||
```
|
||||
|
|
|
@ -43,9 +43,9 @@ add a new secret to your organization.
|
|||
|
||||
<!-- -->
|
||||
```sh
|
||||
curl -XPATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \
|
||||
-H 'Authorization: Token YOURAUTHTOKEN' \
|
||||
-H 'Content-type: application/json' \
|
||||
curl --request PATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \
|
||||
--header 'Authorization: Token YOURAUTHTOKEN' \
|
||||
--header 'Content-type: application/json' \
|
||||
--data '{
|
||||
"<secret-key>": "<secret-value>"
|
||||
}'
|
||||
|
|
|
@ -35,8 +35,8 @@ to delete one or more secrets.
|
|||
|
||||
<!-- -->
|
||||
```bash
|
||||
curl -XGET http://localhost:8086/api/v2/orgs/<org-id>/secrets/delete \
|
||||
--H 'Authorization: Token YOURAUTHTOKEN'
|
||||
curl --request GET http://localhost:8086/api/v2/orgs/<org-id>/secrets/delete \
|
||||
--header 'Authorization: Token YOURAUTHTOKEN' \
|
||||
--data '{
|
||||
"secrets": [
|
||||
"<secret-key>"
|
||||
|
|
|
@ -43,9 +43,9 @@ to update a secret in your organization.
|
|||
|
||||
<!-- -->
|
||||
```sh
|
||||
curl -XPATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \
|
||||
-H 'Authorization: Token YOURAUTHTOKEN' \
|
||||
-H 'Content-type: application/json' \
|
||||
curl --request PATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \
|
||||
--header 'Authorization: Token YOURAUTHTOKEN' \
|
||||
--header 'Content-type: application/json' \
|
||||
--data '{
|
||||
"<secret-key>": "<secret-value>"
|
||||
}'
|
||||
|
|
|
@ -29,6 +29,6 @@ to view your organization's secrets keys.
|
|||
|
||||
<!-- -->
|
||||
```sh
|
||||
curl -XGET http://localhost:8086/api/v2/orgs/<org-id>/secrets \
|
||||
-H 'Authorization: Token YOURAUTHTOKEN'
|
||||
curl --request GET http://localhost:8086/api/v2/orgs/<org-id>/secrets \
|
||||
--header 'Authorization: Token YOURAUTHTOKEN'
|
||||
```
|
||||
|
|
|
@ -94,7 +94,7 @@ When using the InfluxDB API `/write` endpoint to write data, set the `Content-En
|
|||
header to `gzip` to compress the request data.
|
||||
|
||||
```sh
|
||||
curl -XPOST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \
|
||||
curl --request POST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \
|
||||
--header "Authorization: Token YOURAUTHTOKEN" \
|
||||
--header "Content-Encoding: gzip" \
|
||||
--data-raw "mem,host=host1 used_percent=23.43234543 1556896326"
|
||||
|
|
|
@ -108,25 +108,27 @@ The `influx` CLI is installed with **InfluxDB OSS**. If you're using **InfluxDB
|
|||
#### Delete data in InfluxDB Cloud
|
||||
|
||||
```sh
|
||||
curl -X POST 'https://us-west-2-1.aws.cloud2.influxdata.com/api/v2/delete?orgID=<ORGID>'
|
||||
-H 'Authorization: Token <TOKEN WITH WRITE PERMISSIONS'
|
||||
-H 'Content-Type: application/json'
|
||||
-d '{
|
||||
"predicate": "_measurement=\"<MEASUREMENT NAME>\" and _field=\"<FIELD>\"",
|
||||
"start": "2020-08-16T08:00:00Z",
|
||||
"stop": "2020-08-17T08:00:00Z"
|
||||
curl --request POST \
|
||||
https://us-west-2-1.aws.cloud2.influxdata.com/api/v2/delete?orgID=<ORGID> \
|
||||
--header 'Authorization: Token <TOKEN WITH WRITE PERMISSIONS' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"predicate": "_measurement=\"<MEASUREMENT NAME>\" and _field=\"<FIELD>\"",
|
||||
"start": "2020-08-16T08:00:00Z",
|
||||
"stop": "2020-08-17T08:00:00Z"
|
||||
}'
|
||||
```
|
||||
|
||||
#### Delete data in InfluxDB OSS
|
||||
|
||||
```sh
|
||||
curl -XPOST http://localhost:8086/api/v2/delete/?org=myOrg&bucket=myBucket \
|
||||
-H 'Authorization: Token <YOURAUTHTOKEN>' \
|
||||
-d '{
|
||||
"start": "1970-01-01T00:00:00.00Z",
|
||||
"stop": "2020-01-01T00:00:00.00Z"
|
||||
}'
|
||||
curl --request POST http://localhost:8086/api/v2/delete/?org=myOrg&bucket=myBucket \
|
||||
--header 'Authorization: Token <YOURAUTHTOKEN>' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"start": "1970-01-01T00:00:00.00Z",
|
||||
"stop": "2020-01-01T00:00:00.00Z"
|
||||
}'
|
||||
```
|
||||
_For more information, see the [`/delete` API documentation](/influxdb/v2.0/api/#/paths/~1delete/post)._
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ Compressing write requests reduces network bandwidth, but increases server-side
|
|||
{{% /code-tabs %}}
|
||||
{{% code-tab-content %}}
|
||||
```sh
|
||||
curl -XPOST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \
|
||||
curl --request POST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \
|
||||
--header "Authorization: Token YOURAUTHTOKEN" \
|
||||
--data-raw "
|
||||
mem,host=host1 used_percent=23.43234543 1556896326
|
||||
|
@ -48,7 +48,7 @@ mem,host=host2 used_percent=27.18294630 1556896336
|
|||
{{% /code-tab-content %}}
|
||||
{{% code-tab-content %}}
|
||||
```bash
|
||||
curl -XPOST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \
|
||||
curl --request POST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \
|
||||
--header "Authorization: Token YOURAUTHTOKEN" \
|
||||
--header "Content-Encoding: gzip" \
|
||||
--data-raw "
|
||||
|
|
Loading…
Reference in New Issue