updated delete documentation with examples and removed notes, closes #1926
parent
573d99e481
commit
6ebaa53dfb
|
@ -7,6 +7,9 @@ menu:
|
|||
parent: influx
|
||||
weight: 101
|
||||
influxdb/cloud/tags: [delete]
|
||||
related:
|
||||
- /influxdb/cloud/write-data/delete-data
|
||||
- /influxdb/cloud/reference/syntax/delete-predicate
|
||||
---
|
||||
|
||||
{{< duplicate-oss >}}
|
||||
|
|
|
@ -11,6 +11,7 @@ menu:
|
|||
weight: 104
|
||||
influxdb/cloud/tags: [syntax, delete]
|
||||
related:
|
||||
- /influxdb/cloud/write-data/delete-data/
|
||||
- /influxdb/cloud/reference/cli/influx/delete/
|
||||
---
|
||||
|
||||
|
|
|
@ -13,82 +13,5 @@ related:
|
|||
- /influxdb/v2.0/reference/syntax/delete-predicate/
|
||||
- /influxdb/v2.0/reference/cli/influx/delete/
|
||||
---
|
||||
<!--
|
||||
## Delete data in the InfluxDB UI
|
||||
|
||||
Delete data from buckets you've created. You cannot delete data from system buckets.
|
||||
|
||||
### Delete data from buckets
|
||||
|
||||
1. Click **Load Data** in the navigation bar.
|
||||
|
||||
{{< nav-icon "load data" >}}
|
||||
|
||||
2. Select **Buckets**.
|
||||
3. Next to the bucket with data you want to delete, click **Delete Data by Filter**.
|
||||
4. In the **Delete Data** window that appears:
|
||||
- Select a **Target Bucket** to delete data from.
|
||||
- Enter a **Time Range** to delete data from.
|
||||
- Click **+ Add Filter** to filter by tag key and value pair.
|
||||
- Select **I understand that this cannot be undone**.
|
||||
5. Click **Confirm Delete** to delete the selected data.
|
||||
|
||||
### Delete data from the Data Explorer
|
||||
|
||||
1. Click the **Data Explorer** icon in the sidebar.
|
||||
|
||||
{{< nav-icon "data-explorer" >}}
|
||||
|
||||
2. Click **Delete Data** in the top navigation bar.
|
||||
3. In the **Delete Data** window that appears:
|
||||
- Select a **Target Bucket** to delete data from.
|
||||
- Enter a **Time Range** to delete data from.
|
||||
- Click **+ Add Filter** to filter by tag key-value pairs.
|
||||
- Select **I understand that this cannot be undone**.
|
||||
4. Click **Confirm Delete** to delete the selected data.
|
||||
!-->
|
||||
|
||||
Use the `influx` CLI or the InfluxDB API [`/delete`](/influxdb/v2.0/api/#/paths/~1delete/post) endpoint to delete data.
|
||||
|
||||
## Delete data using the influx CLI
|
||||
|
||||
{{% note %}}
|
||||
If you haven't already, download and set up the [`influx` CLI](/influxdb/cloud/get-started/#optional-download-install-and-use-the-influx-cli). Following these setup instructions creates a configuration profile that stores your credentials, including your organization and token.
|
||||
{{% /note %}}
|
||||
|
||||
1. Use the [`influx delete` command](/influxdb/v2.0/reference/cli/influx/delete/) to delete points from InfluxDB.
|
||||
2. If you set up a configuration profile with your organization and token, specify the bucket (`-b`) to delete from. Otherwise, specify your organization (`-o`), bucket (`-b`), and authentication token (`-t`) with write permissions.
|
||||
3. Define the time range to delete data from with the `--start` and `--stop` flags.
|
||||
4. (Optional) Specify which points to delete using the predicate parameter and [delete predicate syntax](/influxdb/v2.0/reference/syntax/delete-predicate/).
|
||||
|
||||
#### Example
|
||||
|
||||
```sh
|
||||
influx delete --bucket my-bucket \
|
||||
--start '1970-01-01T00:00:00.00Z' \
|
||||
--stop '2020-01-01T00:00:00.00Z' \
|
||||
```
|
||||
|
||||
## Delete data using the API
|
||||
|
||||
1. Use the InfluxDB API `/delete` endpoint to delete points from InfluxDB.
|
||||
2. Include your organization and bucket as query parameters in the request URL.
|
||||
3. Use the `Authorization` header to provide your InfluxDB authentication token with write permissions.
|
||||
4. In your request payload, define the time range to delete data from with `start` and `stop`.
|
||||
5. (Optional) Specify which points to delete using the `predicate` parameter and [delete predicate syntax](/influxdb/v2.0/reference/syntax/delete-predicate/).
|
||||
|
||||
#### Example
|
||||
|
||||
```sh
|
||||
curl --request POST \
|
||||
https://cloud2.influxdata.com/api/v2/delete?org=<org-name>&bucket=<bucket-name> \
|
||||
--header 'Authorization: Token <INFLUXDB_AUTH_TOKEN>' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"predicate": "_measurement=\"example-measurement\" and _field=\"example-field\"",
|
||||
"start": "2020-08-16T08:00:00Z",
|
||||
"stop": "2020-08-17T08:00:00Z"
|
||||
}'
|
||||
```
|
||||
|
||||
_For more information, see the [`/delete` API documentation](/influxdb/v2.0/api/#/paths/~1delete/post)._
|
||||
{{< duplicate-oss >}}
|
|
@ -7,32 +7,60 @@ menu:
|
|||
parent: influx
|
||||
weight: 101
|
||||
influxdb/v2.0/tags: [delete]
|
||||
related:
|
||||
- /influxdb/v2.0/write-data/delete-data
|
||||
- /influxdb/v2.0/reference/syntax/delete-predicate
|
||||
---
|
||||
|
||||
The `influx delete` command deletes [points](/influxdb/v2.0/reference/glossary/#point)
|
||||
from an InfluxDB bucket. Identify points to delete using [delete predicate syntax](/influxdb/v2.0/reference/syntax/delete-predicate).
|
||||
|
||||
{{% note %}}
|
||||
In **InfluxDB OSS 2.0rc**, the `influx delete --predicate` flag has been disabled.
|
||||
The `-p`, `--predicate` flag is supported in **InfluxDB Cloud** and **InfluxDB OSS 2.0 beta 16 or earlier**.
|
||||
|
||||
{{% warn %}}
|
||||
Running `influx delete` without the `-p` or `--predicate` flag deletes all data with timestamps between the specified
|
||||
`--start` and `--stop` times in the specified bucket.
|
||||
{{% /note %}}
|
||||
{{% /warn %}}
|
||||
|
||||
## Flags
|
||||
| Flag | | Description | Input type | {{< cli/mapped >}} |
|
||||
|:---- |:--- |:----------- |:----------:|:------------------ |
|
||||
| `-c` | `--active-config` | CLI configuration to use for command | string | |
|
||||
| `-b` | `--bucket` | Name of bucket to remove data from | string | `INFLUX_BUCKET_NAME` |
|
||||
| | `--bucket-id` | Bucket ID | string | `INFLUX_BUCKET_ID` |
|
||||
| | `--configs-path` | Path to `influx` CLI configurations (default `~/.influxdbv2/configs`) | string |`INFLUX_CONFIGS_PATH` |
|
||||
| `-h` | `--help` | Help for the `delete` command | | |
|
||||
| | `--host` | HTTP address of InfluxDB (default `http://localhost:8086`) | string | `INFLUX_HOST` |
|
||||
| `-o` | `--org` | Organization name | string | `INFLUX_ORG` |
|
||||
| | `--org-id` | Organization ID | string | `INFLUX_ORG_ID` |
|
||||
| `-p` | `--predicate` | Only supported in InfluxDB Cloud and InfluxDB OSS 2.0 beta 16 or earlier InfluxQL-like predicate string (see [Delete predicate](/influxdb/v2.0/reference/syntax/delete-predicate)). | string | |
|
||||
| | `--skip-verify` | Skip TLS certificate verification | | |
|
||||
| | `--start` | Start time in RFC3339 format (i.e. `2009-01-02T23:00:00Z`) | string | |
|
||||
| | `--stop` | Stop time in RFC3339 format (i.e. `2009-01-02T23:00:00Z`) | string | |
|
||||
| `-t` | `--token` | Authentication token | string | `INFLUX_TOKEN` |
|
||||
| Flag | | Description | Input type | {{< cli/mapped >}} |
|
||||
|:---- |:--- |:----------- |:----------:|:------------------ |
|
||||
| `-c` | `--active-config` | CLI configuration to use for command | string | |
|
||||
| | `--bucket` | Name of bucket to remove data from | string | `INFLUX_BUCKET_NAME` |
|
||||
| | `--bucket-id` | Bucket ID | string | `INFLUX_BUCKET_ID` |
|
||||
| | `--configs-path` | Path to `influx` CLI configurations (default `~/.influxdbv2/configs`) | string |`INFLUX_CONFIGS_PATH` |
|
||||
| `-h` | `--help` | Help for the `delete` command | | |
|
||||
| | `--host` | HTTP address of InfluxDB (default `http://localhost:8086`) | string | `INFLUX_HOST` |
|
||||
| `-o` | `--org` | Organization name | string | `INFLUX_ORG` |
|
||||
| | `--org-id` | Organization ID | string | `INFLUX_ORG_ID` |
|
||||
| `-p` | `--predicate` | InfluxQL-like predicate string (see [Delete predicate](/influxdb/v2.0/reference/syntax/delete-predicate)) | string | |
|
||||
| | `--skip-verify` | Skip TLS certificate verification | | |
|
||||
| | `--start` | ({{< req >}}) Start time in RFC3339 format (i.e. `2009-01-02T23:00:00Z`) | string | |
|
||||
| | `--stop` | ({{< req >}}) Stop time in RFC3339 format (i.e. `2009-01-02T23:00:00Z`) | string | |
|
||||
| `-t` | `--token` | Authentication token | string | `INFLUX_TOKEN` |
|
||||
|
||||
## Examples
|
||||
|
||||
##### Delete all points in a measurement
|
||||
```sh
|
||||
influx delete \
|
||||
--bucket example-bucket \
|
||||
--start 1970-01-01T00:00:00Z \
|
||||
--stop $(date +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--predicate '_measurement="example-measurement"'
|
||||
```
|
||||
|
||||
##### Delete points in a measurement with a specific tag value
|
||||
```sh
|
||||
influx delete \
|
||||
--bucket example-bucket \
|
||||
--start 1970-01-01T00:00:00Z \
|
||||
--stop $(date +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--predicate '_measurement="example-measurement" AND host="old-host"'
|
||||
```
|
||||
|
||||
##### Delete all points within a specified time frame
|
||||
```sh
|
||||
influx delete \
|
||||
--bucket example-bucket \
|
||||
--start 2020-03-01T00:00:00Z \
|
||||
--stop 2020-11-14T00:00:00Z
|
||||
```
|
|
@ -2,8 +2,8 @@
|
|||
title: Delete predicate syntax
|
||||
list_title: Delete predicate
|
||||
description: >
|
||||
The InfluxDB `/delete` endpoint uses an InfluxQL-like predicate syntax to determine
|
||||
what data points to delete.
|
||||
The InfluxDB `/api/v2/delete` endpoint uses an InfluxQL-like predicate syntax
|
||||
to determine what data points to delete.
|
||||
menu:
|
||||
influxdb_2_0_ref:
|
||||
parent: Syntax
|
||||
|
@ -11,17 +11,12 @@ menu:
|
|||
weight: 104
|
||||
influxdb/v2.0/tags: [syntax, delete]
|
||||
related:
|
||||
- /influxdb/v2.0/write-data/delete-data/
|
||||
- /influxdb/v2.0/reference/cli/influx/delete/
|
||||
---
|
||||
|
||||
{{% note %}}
|
||||
In **InfluxDB OSS 2.0rc**, the delete with predicate API (`/api/v2/delete`) has been disabled and returns a 501 Not implemented message.
|
||||
|
||||
Use the InfluxDB `/delete` endpoint with **InfluxDB Cloud** and **InfluxDB OSS 2.0 beta 16 or earlier**.
|
||||
{{% /note %}}
|
||||
|
||||
The InfluxDB `/delete` endpoint uses an InfluxQL-like predicate syntax to determine
|
||||
what data [points](/influxdb/v2.0/reference/glossary/#point) to delete.
|
||||
The InfluxDB `/api/v2/delete` endpoint uses an InfluxQL-like predicate syntax to
|
||||
determine what data [points](/influxdb/v2.0/reference/glossary/#point) to delete.
|
||||
InfluxDB uses the delete predicate to evaluate the [series keys](/influxdb/v2.0/reference/glossary/#series-key)
|
||||
of points in the time range specified in the delete request.
|
||||
Points with series keys that evaluate to `true` for the given predicate are deleted.
|
||||
|
|
|
@ -13,6 +13,7 @@ related:
|
|||
- /influxdb/v2.0/reference/syntax/delete-predicate/
|
||||
- /influxdb/v2.0/reference/cli/influx/delete/
|
||||
---
|
||||
|
||||
<!--
|
||||
## Delete data in the InfluxDB UI
|
||||
|
||||
|
@ -48,42 +49,84 @@ Delete data from buckets you've created. You cannot delete data from system buck
|
|||
4. Click **Confirm Delete** to delete the selected data.
|
||||
!-->
|
||||
|
||||
Use the `influx` CLI or the InfluxDB API [`/delete`](/influxdb/v2.0/api/#/paths/~1delete/post) endpoint to delete data.
|
||||
Use the `influx` CLI or the InfluxDB API [`/api/v2/delete`](/influxdb/v2.0/api/#operation/PostDelete) endpoint to delete data.
|
||||
|
||||
{{% note %}}
|
||||
The `influx delete --predicate` flag is currently disabled and will be re-enabled in an upcoming release. Deleting data without a predicate deletes all data in the specified bucket with timestamps between the specified `start` and `stop` times.
|
||||
{{% /note %}}
|
||||
{{% warn %}}
|
||||
Deleting data without a [delete predicate](/influxdb/v2.0/reference/syntax/delete-predicate)
|
||||
deletes all data in the specified bucket with timestamps between the specified `start` and `stop` times.
|
||||
{{% /warn %}}
|
||||
|
||||
## Delete data using the influx CLI
|
||||
|
||||
{{% note %}}
|
||||
Use [InfluxDB CLI connection configurations](/influxdb/v2.0/reference/cli/influx/config/)
|
||||
to provide your **InfluxDB host, organization, and authentication token**.
|
||||
{{% /note %}}
|
||||
|
||||
1. Use the [`influx delete` command](/influxdb/v2.0/reference/cli/influx/delete/) to delete points from InfluxDB.
|
||||
2. Specify your organization, bucket, and authentication token.
|
||||
3. Define the time range to delete data from with the `--start` and `--stop` flags.
|
||||
2. Use the `--bucket` flag to specify which bucket to delete data from.
|
||||
3. Use the `--start` and `--stop` flags to define the time range to delete data from.
|
||||
Use [RFC3339 timestamps](/influxdb/v2.0/reference/glossary/#rfc3339-timestamp).
|
||||
4. _(Optional)_ Use the `-p`, `--predicate` flag to include a [delete predicate](/influxdb/v2.0/reference/syntax/delete-predicate)
|
||||
that identifies which points to delete.
|
||||
|
||||
#### Example
|
||||
### Examples
|
||||
|
||||
##### Delete points in a specific measurement with a specific tag value
|
||||
```sh
|
||||
influx delete -o my-org -b my-bucket -t $INFLUX_TOKEN \
|
||||
--start '1970-01-01T00:00:00.00Z' \
|
||||
--stop '2020-01-01T00:00:00.00Z' \
|
||||
influx delete --bucket example-bucket \
|
||||
--start '1970-01-01T00:00:00Z' \
|
||||
--stop $(date +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--predicate '_measurement="example-measurement" AND exampleTag="exampleTagValue"'
|
||||
```
|
||||
|
||||
##### Delete all points in a specified time range
|
||||
```sh
|
||||
influx delete --bucket example-bucket \
|
||||
--start 2020-03-01T00:00:00Z \
|
||||
--stop 2020-11-14T00:00:00Z
|
||||
```
|
||||
|
||||
## Delete data using the API
|
||||
Use the InfluxDB API `/api/v2/delete` endpoint to delete points from InfluxDB.
|
||||
Include the following:
|
||||
|
||||
1. Use the InfluxDB API `/delete` endpoint to delete points from InfluxDB.
|
||||
2. Include your organization and bucket as query parameters in the request URL.
|
||||
3. Use the `Authorization` header to provide your InfluxDB authentication token.
|
||||
4. In your request payload, define the time range to delete data from with `start` and `stop`.
|
||||
- **Request method:** `POST`
|
||||
- **Headers:**
|
||||
- **Authorization:** `Token` schema with your InfluxDB authentication token
|
||||
- **Content-type:** `application/json`
|
||||
- **Query parameters:**
|
||||
- **org** or **orgID:** organization name or [organization ID](/influxdb/v2.0/organizations/view-orgs/#view-your-organization-id)
|
||||
- **bucket** or **bucketID:** bucket name or [bucket ID](/influxdb/v2.0/organizations/buckets/view-buckets/)
|
||||
- **Request body:** JSON object with the following fields:
|
||||
{{< req type="key" >}}
|
||||
- {{< req "\*" >}} **start:** earliest time to delete data from ([RFC3339](/influxdb/v2.0/reference/glossary/#rfc3339-timestamp))
|
||||
- {{< req "\*" >}} **stop:** latest time to delete data from ([RFC3339](/influxdb/v2.0/reference/glossary/#rfc3339-timestamp))
|
||||
- **predicate:** [delete predicate](/influxdb/v2.0/reference/syntax/delete-predicate) statement
|
||||
|
||||
#### Example
|
||||
#### Examples
|
||||
|
||||
##### Delete points in a specific measurement with a specific tag value
|
||||
```sh
|
||||
curl --request POST http://localhost:8086/api/v2/delete/?org=myOrg&bucket=myBucket \
|
||||
curl --request POST http://localhost:8086/api/v2/delete/?org=example-org&bucket=example-bucket \
|
||||
--header 'Authorization: Token <YOURAUTHTOKEN>' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"start": "1970-01-01T00:00:00.00Z",
|
||||
"stop": "2020-01-01T00:00:00.00Z"
|
||||
"start": "2020-03-01T00:00:00Z",
|
||||
"stop": "2020-11-14T00:00:00Z",
|
||||
"predicate": "_measurement=\"example-measurement\" AND exampleTag=\"exampleTagValue\""
|
||||
}'
|
||||
```
|
||||
_For more information, see the [`/delete` API documentation](/influxdb/v2.0/api/#/paths/~1delete/post)._
|
||||
|
||||
##### Delete all points in a specified time range
|
||||
```sh
|
||||
curl --request POST http://localhost:8086/api/v2/delete/?org=example-org&bucket=example-bucket \
|
||||
--header 'Authorization: Token <YOURAUTHTOKEN>' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"start": "2020-03-01T00:00:00Z",
|
||||
"stop": "2020-11-14T00:00:00Z"
|
||||
}'
|
||||
```
|
||||
|
||||
_For more information, see the [`/api/v2/delete` endpoint documentation](/influxdb/v2.0/api/#operation/PostDelete)._
|
||||
|
|
Loading…
Reference in New Issue