root@dev1:~# influx
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 0.13.0
InfluxDB shell version: 0.13.0
>
> show databases
name: databases
-------------
name
_internal
test
> use test
Using database test
> show measurements
name: measurements
------------------
name
ceph_cluster
> show tag values from ceph_cluster with key=type_instance
name: ceph_cluster
------------------
key value
type_instance cluster.free
type_instance cluster.health
type_instance cluster.iops
> show tag values from ceph_cluster with key in (type, type_instance)
name: ceph_cluster
------------------
key value
type ceph_cluster
type_instance cluster.free
type_instance cluster.health
type ceph_mon
> show tag values from ceph_cluster with key in (type, type_instance) where host='dev2'
>
> show series from ceph_cluster
key
ceph_cluster,host=dev1,type=ceph_cluster,type_instance=cluster.free,unit=MB
ceph_cluster,host=dev1,type=ceph_cluster,type_instance=cluster.total,unit=MB
ceph_cluster,host=dev1,type=ceph_cluster,type_instance=cluster.used,unit=MB
ceph_cluster,host=dev1,type=ceph_mon,type_instance=cluster.mon.quorum_num
ceph_cluster,host=dev1,type=ceph_mon,type_instance=cluster.mon.total_num
> select * from ceph_cluster limit 5
name: ceph_cluster
------------------
time host type type_instance unit value
1499212809488769000 dev1 ceph_cluster cluster.used MB 58266.52734375
1499212809488819000 dev1 ceph_cluster cluster.total MB 245633.90625
1499212809488885000 dev1 ceph_cluster cluster.free MB 187367.37890625
1499212809491293000 dev1 ceph_cluster cluster.health 0
1499212809491349000 dev1 ceph_cluster cluster.iops 0
> precision rfc3339
> select * from ceph_cluster limit 5
name: ceph_cluster
------------------
time host type type_instance unit value
2017-07-05T00:00:09.488769Z dev1 ceph_cluster cluster.used MB 58266.52734375
2017-07-05T00:00:09.488819Z dev1 ceph_cluster cluster.total MB 245633.90625
2017-07-05T00:00:09.488885Z dev1 ceph_cluster cluster.free MB 187367.37890625
2017-07-05T00:00:09.491293Z dev1 ceph_cluster cluster.health 0
2017-07-05T00:00:09.491349Z dev1 ceph_cluster cluster.iops 0
> select * from ceph_cluster order by desc limit 5
name: ceph_cluster
------------------
time host type type_instance unit value
2017-08-04T01:48:49.521545Z dev1 ceph_pg cluster.pg.active+clean 1024
2017-08-04T01:48:49.521501Z dev1 ceph_pg cluster.pg.nums 1024
2017-08-04T01:48:49.507881Z dev1 ceph_osd cluster.osd.down 0
2017-08-04T01:48:49.507831Z dev1 ceph_osd cluster.osd.up 6
2017-08-04T01:48:49.507803Z dev1 ceph_osd cluster.osd.out 0
> select * from ceph_cluster where type='ceph_pg' order by desc limit 5
name: ceph_cluster
------------------
time host type type_instance unit value
2017-08-04T01:49:19.517004Z dev1 ceph_pg cluster.pg.active+clean 1024
2017-08-04T01:49:19.516957Z dev1 ceph_pg cluster.pg.nums 1024
2017-08-04T01:49:09.509483Z dev1 ceph_pg cluster.pg.active+clean 1024
2017-08-04T01:49:09.509424Z dev1 ceph_pg cluster.pg.nums 1024
2017-08-04T01:48:59.518189Z dev1 ceph_pg cluster.pg.active+clean 1024
> select * from ceph_cluster where type_instance='cluster.pg.active+clean' and time > now() - 1h and time < now() - 10m order by desc limit 5
name: ceph_cluster
------------------
time host type type_instance unit value
2017-08-04T02:16:59.501857Z dev1 ceph_pg cluster.pg.active+clean 1024
2017-08-04T02:16:49.505655Z dev1 ceph_pg cluster.pg.active+clean 1024
2017-08-04T02:16:39.524362Z dev1 ceph_pg cluster.pg.active+clean 1024
2017-08-04T02:16:29.512281Z dev1 ceph_pg cluster.pg.active+clean 1024
2017-08-04T02:16:19.517638Z dev1 ceph_pg cluster.pg.active+clean 1024
注:
时间可以是具体的时间戳,也可以是上面那种时间偏移。
> select mean(value) from ceph_cluster where type_instance='cluster.pg.active+clean' and time > now() - 1h and time < now() - 10m order by desc limit 5
name: ceph_cluster
------------------
time mean
2017-08-04T01:30:08.159324342Z 1024
> select max(value) from ceph_cluster where type_instance='cluster.pg.active+clean' and time > now() - 1h and time < now() - 10m order by desc limit 5
name: ceph_cluster
------------------
time max
2017-08-04T02:20:49.513249Z 1024
> select last(value) from ceph_cluster where type_instance='cluster.pg.active+clean' and time > now() - 1h and time < now() - 10m order by desc limit 5
name: ceph_cluster
------------------
time last
2017-08-04T02:22:19.509789Z 1024
> select mean(value) from ceph_cluster where type_instance='cluster.pg.active+clean' and time > now() - 1h and time < now() - 10m group by time(10m)
name: ceph_cluster
------------------
time mean
2017-08-04T01:30:00Z 1024
2017-08-04T01:40:00Z 1024
2017-08-04T01:50:00Z 1024
2017-08-04T02:00:00Z 1024
2017-08-04T02:10:00Z 1024
2017-08-04T02:20:00Z 1024
> select mean(value) from ceph_cluster where type='ceph_pg' and time > now() - 1h and time < now() - 10m group by type_instance
name: ceph_cluster
tags: type_instance=cluster.pg.active+clean
time mean
---- ----
2017-08-04T01:35:59.515665887Z 1024
--
name: ceph_cluster
tags: type_instance=cluster.pg.nums
time mean
---- ----
2017-08-04T01:35:59.515665887Z 1024
> select count(value) from ceph_cluster where type='ceph_pg' and time > now() - 1h and time < now() - 10m
name: ceph_cluster
------------------
time count
2017-08-04T01:40:00.016998982Z 600
> select * from ceph_cluster where type_instance =~ /cluster.osd/ order by desc limit 5
name: ceph_cluster
------------------
time host type type_instance unit value
2017-08-04T02:42:59.503222Z dev1 ceph_osd cluster.osd.down 0
2017-08-04T02:42:59.503201Z dev1 ceph_osd cluster.osd.up 6
2017-08-04T02:42:59.50318Z dev1 ceph_osd cluster.osd.out 0
2017-08-04T02:42:59.503159Z dev1 ceph_osd cluster.osd.in 6
2017-08-04T02:42:59.503137Z dev1 ceph_osd cluster.osd.total 6
> select * from ceph_cluster where type_instance !~ /cluster.osd/ order by desc limit 5
name: ceph_cluster
------------------
time host type type_instance unit value
2017-08-04T02:43:39.53797Z dev1 ceph_pg cluster.pg.active+clean 1024
2017-08-04T02:43:39.537936Z dev1 ceph_pg cluster.pg.nums 1024
2017-08-04T02:43:39.494511Z dev1 ceph_mon cluster.mon.quorum_num 3
2017-08-04T02:43:39.494489Z dev1 ceph_mon cluster.mon.total_num 3
2017-08-04T02:43:39.494454Z dev1 ceph_cluster cluster.read.bandwidth MB/s 0
> delete from system_disk where instance='dm-0' or instance='dm-1' or instance='rbd0' or instance='rbd1'
>
> delete from system_cpu where type_instance='cpu.used' and time < now() - 1h
>
> drop database test
>
> show databases
name: databases
---------------
name
_internal
> show subscriptions
name: collectd
--------------
retention_policy name mode destinations
default kapacitor-24697dad-aa7d-4ed7-b634-d6c00ff7b2de ANY [udp://localhost:41148]
common kapacitor-24697dad-aa7d-4ed7-b634-d6c00ff7b2de ANY [udp://localhost:55940]
longterm kapacitor-24697dad-aa7d-4ed7-b634-d6c00ff7b2de ANY [udp://localhost:35278]
name: _internal
---------------
retention_policy name mode destinations
monitor kapacitor-24697dad-aa7d-4ed7-b634-d6c00ff7b2de ANY [udp://localhost:56977]
name: physics_monitor
---------------------
retention_policy name mode destinations
default kapacitor-24697dad-aa7d-4ed7-b634-d6c00ff7b2de ANY [udp://localhost:33502]
name: docker_monitor
--------------------
retention_policy name mode destinations
default kapacitor-24697dad-aa7d-4ed7-b634-d6c00ff7b2de ANY [udp://localhost:51330]
name: k8s
---------
retention_policy name mode destinations
default kapacitor-24697dad-aa7d-4ed7-b634-d6c00ff7b2de ANY [udp://localhost:52220]
> show retention policies on collectd
name duration shardGroupDuration replicaN default
default 168h0m0s 24h0m0s 1 true
common 1h0m0s 1h0m0s 1 false
longterm 2h0m0s 1h0m0s 1 false
> create retention policy test on test duration 7d replication 1 default
>
> show retention policies on test
name duration shardGroupDuration replicaN default
default 0 168h0m0s 1 false
test 168h0m0s 24h0m0s 1 true
> alter retention policy test on test duration 1d default
>
> show retention policies on test
name duration shardGroupDuration replicaN default
default 0 168h0m0s 1 false
test 24h0m0s 1h0m0s 1 true