From bb42c7d8a8ae8ca0110553be61ed533f3d0f27e5 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 4 Oct 2022 14:51:59 -0600 Subject: [PATCH] add notes about and examples of deleting data, closes #4524 (#4525) --- .../reference/cli/influx/delete/_index.md | 11 ++++++ .../v2.4/reference/syntax/delete-predicate.md | 17 +++++++- .../influxdb/v2.4/write-data/delete-data.md | 39 ++++++++++++++++++- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/content/influxdb/v2.4/reference/cli/influx/delete/_index.md b/content/influxdb/v2.4/reference/cli/influx/delete/_index.md index a498fca52..c3e9e850d 100644 --- a/content/influxdb/v2.4/reference/cli/influx/delete/_index.md +++ b/content/influxdb/v2.4/reference/cli/influx/delete/_index.md @@ -21,10 +21,21 @@ from an InfluxDB bucket in a specified time range. Select points to delete within the specified time range using [delete predicate syntax](/influxdb/v2.4/reference/syntax/delete-predicate). {{% warn %}} +#### Deleting data without a delete predicate + 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. + +{{% oss-only %}} + +#### Cannot delete data by field + +InfluxDB {{< current-version >}} does not support deleting data **by field**. + +{{% /oss-only %}} {{% /warn %}} + ## Flags | Flag | | Description | Input type | {{< cli/mapped >}} | |:-----|:------------------|:----------------------------------------------------------------------------------------------------------|:----------:|:----------------------| diff --git a/content/influxdb/v2.4/reference/syntax/delete-predicate.md b/content/influxdb/v2.4/reference/syntax/delete-predicate.md index 4771a19f7..f9deed83c 100644 --- a/content/influxdb/v2.4/reference/syntax/delete-predicate.md +++ b/content/influxdb/v2.4/reference/syntax/delete-predicate.md @@ -31,9 +31,22 @@ Use [logical operators](#logical-operators) to combine two or more predicate exp ```sql key1="value1" AND key2="value" ``` + {{% warn %}} -With **InfluxDB {{< current-version >}}**, delete predicates can use any column -or tag **except** `_time`{{% oss-only %}}, `_field`, {{% /oss-only %}}or `_value`. +#### Column limitations when deleting data +**InfluxDB {{< current-version >}}** supports deleting data by any column or tag +_**except**_ the following: + +- `_time` +- {{% oss-only %}}`_field`{{% /oss-only %}} +- `_value` + +{{% oss-only %}} + +_InfluxDB {{< current-version >}} does not support deleting data **by field**._ + +{{% /oss-only %}} + {{% /warn %}} ## Logical operators diff --git a/content/influxdb/v2.4/write-data/delete-data.md b/content/influxdb/v2.4/write-data/delete-data.md index 2fae1c687..3f9b5dec6 100644 --- a/content/influxdb/v2.4/write-data/delete-data.md +++ b/content/influxdb/v2.4/write-data/delete-data.md @@ -32,7 +32,8 @@ InfluxDB {{< current-version >}} supports deleting data by the following: {{% oss-only %}} {{% warn %}} -InfluxDB {{< current-version >}} does not support deleting data by field. +#### Cannot delete data by field +InfluxDB {{< current-version >}} does not support deleting data **by field**. {{% /warn %}} {{% /oss-only %}} @@ -76,6 +77,10 @@ deletes all data in the specified bucket with timestamps between the specified ` ### Examples +- [Delete points in a specific measurement with a specific tag value](#delete-points-in-a-specific-measurement-with-a-specific-tag-value) +- [Delete all points in a specified time range](#delete-all-points-in-a-specified-time-range) +- {{% cloud-only %}}[Delete points for a specific field in a specified time range](#delete-points-for-a-specific-field-in-a-specified-time-range){{% /cloud-only %}} + ##### Delete points in a specific measurement with a specific tag value ```sh influx delete --bucket example-bucket \ @@ -91,6 +96,18 @@ influx delete --bucket example-bucket \ --stop 2020-11-14T00:00:00Z ``` +{{% cloud-only %}} + +##### Delete points for a specific field in a specified time range +```sh +influx delete --bucket example-bucket \ + --start 2022-01-01T00:00:00Z \ + --stop 2022-02-01T00:00:00Z \ + --predicate '_field="example-field"' +``` + +{{% /cloud-only %}} + ## Delete data using the API Use the InfluxDB API [`/api/v2/delete` endpoint](/influxdb/v2.4/api/#operation/PostDelete) to delete points from InfluxDB. @@ -119,6 +136,10 @@ deletes all data in the specified bucket with timestamps between the specified ` ### Examples +- [Delete points in a specific measurement with a specific tag value](#delete-points-in-a-specific-measurement-with-a-specific-tag-value-1) +- [Delete all points in a specified time range](#delete-all-points-in-a-specified-time-range-1) +- {{% cloud-only %}}[Delete points for a specific field in a specified time range](#delete-points-for-a-specific-field-in-a-specified-time-range-1){{% /cloud-only %}} + ##### Delete points in a specific measurement with a specific tag value ```sh curl --request POST http://localhost:8086/api/v2/delete?org=example-org&bucket=example-bucket \ @@ -142,4 +163,20 @@ curl --request POST http://localhost:8086/api/v2/delete?org=example-org&bucket=e }' ``` +{{% cloud-only %}} + +##### Delete points for a specific field in a specified time range +```sh +curl --request POST http://localhost:8086/api/v2/delete?org=example-org&bucket=example-bucket \ + --header 'Authorization: Token YOUR_API_TOKEN' \ + --header 'Content-Type: application/json' \ + --data '{ + "start": "2022-01-01T00:00:00Z", + "stop": "2022-02-01T00:00:00Z", + "predicate": "_field=\"example-field\"" + }' +``` + +{{% /cloud-only %}} + _For more information, see the [`/api/v2/delete` endpoint documentation](/influxdb/v2.4/api/#operation/PostDelete)._