Category Archives: Dev/Infra Tools

#InfluxDB : readable timestamps in the CLI

Time-series database InfluxDB provides a nice CLI, similar to what is available for many other databases.
One key feature of the interaction with time series databases is to work a lot with time, so it comes a little bit surprising that InfluxDB displays time as nanoseconds timestamp, like the following:


To have human-readable timestamps invoke the CLI as the following:

$influx -precision rfc3339

or type the following command at the CLI propmpt:

> precision rfc3339

The timestamp will then look like:


better right? 🙂


#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:


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}'`;
influx -username root -password root -database forecasting -execute 'drop measurement "${mes}"';

%d bloggers like this: