Delete data
Use the influx CLI or the InfluxDB API /api/v2/delete endpoint to delete data from an InfluxDB bucket.
InfluxDB 2.7 supports deleting data by the following:
- time range
- measurement (
_measurement) - tag
Cannot delete data by field
InfluxDB 2.7 does not support deleting data by field.
Once a delete request completes successfully, 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.
- Use the influx delete command to delete points from InfluxDB.
- Use the
--bucketflag to specify which bucket to delete data from. - Use the
--startand--stopflags to define the time range to delete data from. Use RFC3339 timestamps. - (Optional) Use the
-p,--predicateflag 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
- Delete all points in a specified time range
Delete points in a specific measurement with a specific tag value
1. influx delete --bucket example-bucket \
2. --start '1970-01-01T00:00:00Z' \
3. --stop $(date -u +"%Y-%m-%dT%H:%M:%SZ") \
4. --predicate '_measurement="example-measurement" AND exampleTag="exampleTagValue"'
Delete all points in a specified time range
1. influx delete --bucket example-bucket \
2. --start 2020-03-01T00:00:00Z \
3. --stop 2020-11-14T00:00:00Z
Delete data using the API
Use the InfluxDB API /api/v2/delete endpoint to delete points from InfluxDB.
1. POST http://localhost:8086/api/v2/delete
Include the following:
- Request method:
POST - Headers:
- Authorization:
Tokenschema with your InfluxDB API token - Content-type:
application/json - 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: * 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
startandstoptimes.
Examples
- Delete points in a specific measurement with a specific tag value
- Delete all points in a specified time range
Delete points in a specific measurement with a specific tag value
1. curl --request POST http://localhost:8086/api/v2/delete?org=example-org&bucket=example-bucket \
2. --header 'Authorization: Token YOUR_API_TOKEN' \
3. --header 'Content-Type: application/json' \
4. --data '{
5. "start": "2020-03-01T00:00:00Z",
6. "stop": "2020-11-14T00:00:00Z",
7. "predicate": "_measurement=\"example-measurement\" AND exampleTag=\"exampleTagValue\""
8. }'
Delete all points in a specified time range
1. curl --request POST http://localhost:8086/api/v2/delete?org=example-org&bucket=example-bucket \
2. --header 'Authorization: Token YOUR_API_TOKEN' \
3. --header 'Content-Type: application/json' \
4. --data '{
5. "start": "2020-03-01T00:00:00Z",
6. "stop": "2020-11-14T00:00:00Z"
7. }'
For more information, see the /api/v2/delete endpoint documentation.
To delete a bucket see Delete a bucket.
