#InfluxDB : drop all measurements
InfluxDB is a popular time series databases. Its popularity comes from the fact that it is relatively easy to set up, it has relatively high performances, and InfluxQL, a simple SQL-like query language (which is being superseded by flux for a host of reasons).
That said, DB management functions are really important and while playing around with your algorithms (e.g., while doing time series forecasting) you might end up generating quite a few measurements (Influx jargon for table/collection) which we might want to delete at one…If it wasn’t for the fact we can’t!
At least we can drop the whole database (let’s say we have a db named forecasting):
DROP DATABASE forecasting
but if that solution does not work for you (e.g., because you do not have such right, or because you set up some specific retention policies) we are left with a couple of solutions.
Solution 1 does not work on all versions, it is slow, but can be invoked from within Influx shell:
DROP SERIES FROM /.*/
Solution 2 is a simple bash script:
for mes in `influx -username root -password root -database forecasting -execute 'show measurements' --format csv | awk -F "\"*,\"*" '{print $2}'`;
do
influx -username root -password root -database forecasting -execute 'drop measurement "${mes}"';
done
Posted on March 5, 2019, in Dev/Infra Tools and tagged Data Processing, influxdb, time series. Bookmark the permalink. Leave a comment.
Leave a comment
Comments 0