Documentation

Delete data

Use the influx CLI or the InfluxDB API /api/v2/delete endpoint to delete data from an InfluxDB bucket.

InfluxDB Cloud supports deleting data by the following:

  • time range
  • measurement (_measurement)
  • tag
  • field (_field)

In InfluxDB Cloud, writes and deletes are asynchronous and eventually consistent. Once InfluxDB validates your request and queues the delete, it sends a success response (HTTP 204 status code) as an acknowledgement. To ensure that InfluxDB handles writes and deletes in the order you request them, wait for the acknowledgement before you send the next request. Once InfluxDB executes a queued delete, the deleted data is no longer queryable, but will remain on disk until the compaction service runs.

Delete data using the influx CLI

Use InfluxDB CLI connection configurations to provide your InfluxDB host, organization, and API token.

  1. Use the influx delete command to delete points from InfluxDB.

  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.

  4. (Optional) Use the -p, --predicate flag to include a delete predicate that identifies which points to delete.

    Deleting data without a delete predicate deletes all data in the specified bucket with timestamps between the specified start and stop times.

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 -u +"%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 points for a specific field in a specified time range
influx delete --bucket example-bucket \
  --start 2022-01-01T00:00:00Z \
  --stop 2022-02-01T00:00:00Z \
  --predicate '_field="example-field"'

Delete data using the API

Use the InfluxDB API /api/v2/delete endpoint to delete points from InfluxDB.

POST http://localhost:8086/api/v2/delete

Include the following:

  • Request method: POST
  • Headers:
    • Authorization: Token schema with your InfluxDB API token
    • Content-type: application/json
  • Query parameters:
  • Request body: JSON object with the following fields:
    * Required
    • * start: earliest time to delete data from (RFC3339)

    • * stop: latest time to delete data from (RFC3339)

    • predicate: delete predicate statement

      Deleting data without a delete predicate deletes all data in the specified bucket with timestamps between the specified start and stop times.

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"
  }'
Delete points for a specific field 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": "2022-01-01T00:00:00Z",
    "stop": "2022-02-01T00:00:00Z",
    "predicate": "_field=\"example-field\""
  }'

For more information, see the /api/v2/delete endpoint documentation.

To delete a bucket see Delete a bucket.


Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB v3 enhancements and InfluxDB Clustered is now generally available

New capabilities, including faster query performance and management tooling advance the InfluxDB v3 product line. InfluxDB Clustered is now generally available.

InfluxDB v3 performance and features

The InfluxDB v3 product line has seen significant enhancements in query performance and has made new management tooling available. These enhancements include an operational dashboard to monitor the health of your InfluxDB cluster, single sign-on (SSO) support in InfluxDB Cloud Dedicated, and new management APIs for tokens and databases.

Learn about the new v3 enhancements


InfluxDB Clustered general availability

InfluxDB Clustered is now generally available and gives you the power of InfluxDB v3 in your self-managed stack.

Talk to us about InfluxDB Clustered

InfluxDB Cloud powered by TSM