$ influx
Note: There is another CLI to influx that can be installed through python pypi.
You can search there for influx-prompt
. It does not coexist very well with
other db CLIs like mycli or pgcli, so you probably should install it on a
separate virtualenv.
$ SHOW DATABASES
$ USE collectd;
$ SHOW MEASUREMENTS
$ SELECT * FROM memory_value;
SELECT time, mean(value)/1000000 AS mean_value_in_mb FROM memory_value WHERE type_instance = 'free' GROUP BY time(20m) ORDER BY time DESC;
(GROUP BY queries imply an aggregation - in this case, mean(value). It could be count(value), etc...)
time
column as human-readable timestamp:$ PRECISION RFC3339
$ influxd backup -database collectd /tmp/influxdb.backup
$ influxd backup -database collectd -start 2017-04-28T06:49:00Z -end 2017-04-28T06:50:00Z /tmp/influxdb.backup
$ sudo influxd restore -database collectd -datadir /var/lib/influxdb/data /tmp/influxdb.backup/
$ influx -execute "CREATE USER admin WITH PASSWORD 'mysecret' WITH ALL PRIVILEGES";
You must also edit influxdb.conf
and enable the authentication there.
After that, you will not be able to do queries on influx cli without specifying
the username and password. You will be able to connect to influx, but all
operations will return errors. Below are some examples on how to access the
cli, one to enter commands interactively and another to run a specific command
and quit.
$ influx -username admin -password mysecret
$ influx -username admin -password mysecret -execute "SHOW USERS";