InfluxDB 2.x - Delete Measurement Using API or Docker Container Shell


I regularly delete a ‘sandbox’ measurement with test data. It is not very complicated to delete a measurement, but it is worth noting. You can do this via the InfluxDB v2 API or via the shell of the InfluxDB 2.x Docker container. Both options are described here.

InfluxDB v2 API

The InfluxDB v2 API makes it very easy to remove a measurement from the docker host’s CLI with cURL. And of course it is also possible to use tools like Node-RED or Pentaho to make an HTTP call to the API.

Run the following command on the CLI of the Docker host:

  curl --request POST "http://IP:PORT/api/v2/delete?org=ORG&bucket=BUCKET" \
  --header 'Authorization: Token YOUR-TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "start": "1970-01-01T00:00:00Z",
    "stop": "2025-12-31T23:59:00Z",
    "predicate": "_measurement=\"MEASUREMENT\""
  }'

Adjust the following:

IP
Replace with the IP address of InfluxDB. In my case this was the IP address of the Docker host

PORT
Replace with the port used for InfluxDB. Usually this is port 8086. My own InfluxDB container runs on port 3004

ORG
Replace with the name of your InfluxDB Organization. In my case this was ubuntuvm

BUCKET
Replace with the name of your InfluxDB Bucket. In my case this was stock

YOUR-TOKEN
Replace with your token. In my case this was the token with access to the stock Bucket

MEASUREMENT
Replace with the name of the measurement you want to delete. In my case this was sandbox_added_symbols


Docker Container Shell

Another method to remove a measurement is via the shell of the InfluxDB container using the influx CLI.

Open a shell in the container:

docker exec -it influxdb /bin/bash

Now run the following command:

influx delete --bucket "BUCKET" --org "ORG" --predicate '_measurement="MEASUREMENT"' --start "1970-01-01T00:00:00Z" --stop "2025-12-31T23:59:00Z" --token "TOKEN"

Adjust the following:

BUCKET
Replace with the name of your InfluxDB Bucket. In my case this was stock

ORG
Replace with the name of your InfluxDB Organization. In my case this was ubuntuvm

MEASUREMENT
Replace with the name of the measurement you want to delete. In my case this was sandbox_added_symbols

TOKEN
Replace with your token. In my case this was the token with access to the stock Bucket

If everything went well, the entire measurement has been deleted. Now you can exit the container shell and go back to the docker host CLI:

exit

Read other notes

Comments

    No comments found for this note.

    Join the discussion for this note on this ticket. Comments appear on this page instantly.

    Tags


    Notes mentioning this note


    Notes Graph