Clear data from influxdb

Hello There,

I am new to influxdb, can you please let me know how I can remove data from measurement from influxdb hosted in docker container like below.

docker exec -it influxpod – influx {clear data from measurement }

please help me how I can don this, yes we are working on API part but it will be helpful if I get some guidance for above command.


You should be able to use the standard CLI commands with the Docker container, there’s some documentation on how to delete data here: influx delete | InfluxDB OSS 2.0 Documentation

Just as a quick example, a command like this should work, assuming you have a config setup with your token. There are other configuration options you’ll want to take a look at in the delete docs:

docker exec -it influx_container_name influx delete --org org --bucket bucket --start 2009-01-02T23:00:00Z --stop 2009-01-03T23:00:00Z

Thank you wbaker

can you help if we can delete specific measurement from host in influxdb container like below

docker exec -it influx_container_name influx DROP measurement workers

if yes where and how I can provide db name in above command,

also is there any way to store only latest data I can see if I trigger queries it gets duplicated records with new time stamp for example

1123 worker new-timestamp
1123 worker old-timestamp

because of this I am planning to remove data first and insert new each time when my script is executed.

Please guide.


To delete specific data like data with a certain measurement, you can use the --delete flag to specific a predicate. There are some examples at influx delete | InfluxDB OSS 2.0 Documentation which illustrate what you are wanting to do.