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

  1. Use the influx delete command 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.
  4. (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

  1. influx delete -o my-org -b my-bucket -t $INFLUX_TOKEN \
  2. --start '1970-01-01T00:00:00.00Z' \
  3. --stop '2020-01-01T00:00:00.00Z' \
  4. --predicate '_measurement="sensors" and sensorID="abc123"'

Delete data in InfluxDB OSS

  1. influx delete -o my-org -b my-bucket -t $INFLUX_TOKEN \
  2. --start '1970-01-01T00:00:00.00Z' \
  3. --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.

  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.
  5. (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

  1. curl --request POST \
  2. https://us-west-2-1.aws.cloud2.influxdata.com/api/v2/delete?orgID=<ORGID> \
  3. --header 'Authorization: Token <TOKEN WITH WRITE PERMISSIONS' \
  4. --header 'Content-Type: application/json' \
  5. --data '{
  6. "predicate": "_measurement=\"<MEASUREMENT NAME>\" and _field=\"<FIELD>\"",
  7. "start": "2020-08-16T08:00:00Z",
  8. "stop": "2020-08-17T08:00:00Z"
  9. }'

Delete data in InfluxDB OSS

  1. curl --request POST http://localhost:8086/api/v2/delete/?org=myOrg&bucket=myBucket \
  2. --header 'Authorization: Token <YOURAUTHTOKEN>' \
  3. --header 'Content-Type: application/json' \
  4. --data '{
  5. "start": "1970-01-01T00:00:00.00Z",
  6. "stop": "2020-01-01T00:00:00.00Z"
  7. }'

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.

Related articles

delete