5.3 KiB
title | list_title | description | menu | weight | influxdb/v2.1/tags | related | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Delete data | Delete data | Delete data in the InfluxDB CLI and API. |
|
107 |
|
|
Use the influx
CLI or the InfluxDB API
/api/v2/delete
endpoint to delete data.
Delete data using the influx CLI
{{% note %}} Use InfluxDB CLI connection configurations to provide your InfluxDB host, organization, and API token. {{% /note %}}
-
Use the
influx delete
command to delete points from InfluxDB. -
Use the
--bucket
flag to specify which bucket to delete data from. -
Use the
--start
and--stop
flags to define the time range to delete data from. Use RFC3339 timestamps. -
(Optional) Use the
-p
,--predicate
flag to include a delete predicate that identifies which points to delete.{{% warn %}} Deleting data without a delete predicate deletes all data in the specified bucket with timestamps between the specified
start
andstop
times. {{% /warn %}}
Examples
Delete points in a specific measurement with a specific tag value
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
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:
- Request method:
POST
- Headers:
- Authorization:
Token
schema with your InfluxDB API token - Content-type:
application/json
- Authorization:
- Query parameters:
- org or orgID: organization name or organization ID
- bucket or bucketID: bucket name or bucket ID
- Request body: JSON object with the following fields:
{{< req type="key" >}}-
{{< req "*" >}} start: earliest time to delete data from (RFC3339)
-
{{< req "*" >}} stop: latest time to delete data from (RFC3339)
-
predicate: delete predicate statement
{{% warn %}} Deleting data without a delete predicate deletes all data in the specified bucket with timestamps between the specified
start
andstop
times. {{% /warn %}}
-
Examples
Delete points in a specific measurement with a specific tag value
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": "2020-03-01T00:00:00Z",
"stop": "2020-11-14T00:00:00Z",
"predicate": "_measurement=\"example-measurement\" AND exampleTag=\"exampleTagValue\""
}'
Delete all points in a specified time range
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": "2020-03-01T00:00:00Z",
"stop": "2020-11-14T00:00:00Z"
}'
For more information, see the /api/v2/delete
endpoint documentation.