Delete data
Use the influx
CLI or the InfluxDB API /delete
endpoint to delete data.
In InfluxDB OSS 2.0, 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.
Delete data using the influx CLI
- Use the
influx delete
command to delete points from InfluxDB. - Specify your organization, bucket, and authentication token.
- Define the time range to delete data from with the
--start
and--stop
flags. - (InfluxDB Cloud only) Specify which points to delete using the predicate parameter and delete predicate syntax.
Example delete commands
InfluxDB OSS 2.0rc does not support the predicate
parameter.
Delete data in InfluxDB Cloud
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' \
--predicate '_measurement="sensors" and sensorID="abc123"'
Delete data in InfluxDB OSS
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' \
Deleting data in OSS (because the -p
or --predicate
flag is not implemented) deletes all data with timestamps between the specified --start
and --stop
times in the specified bucket.
Delete data using the API
The influx
CLI is installed with InfluxDB OSS. If you’re using InfluxDB Cloud and haven’t already, download the influx
CLI.
- Use the InfluxDB API
/delete
endpoint to delete points from InfluxDB. - Include your organization and bucket as query parameters in the request URL.
- Use the
Authorization
header to provide your InfluxDB authentication token. - In your request payload, define the time range to delete data from with
start
andstop
. - (InfluxDB Cloud only): Specify which points to delete using the
predicate
parameter and Delete predicate syntax.
Example delete requests
InfluxDB OSS 2.0rc does not support the predicate
parameter.
Delete data in InfluxDB Cloud
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
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.
Using the /delete
endpoint without a predicate
deletes all data with timestamps between the specified start
and stop
times in the specified bucket.