您的位置:首页 > 数据库

时序数据库InfluxDB

2017-12-22 10:53 274 查看

时序数据库InfluxDB

官网:https://www.influxdata.com/

参考文档:https://docs.influxdata.com/influxdb/v1.3/administration/config/#configuration-options-overview

简介

InfluxDB支持的时间级别到了纳秒(ns),所以到数据的操作也应该到纳秒级。

http的使用

GET:
SELECT*
SHOW


POST:
ALTER
CREATE
DELETE
DROP
GRANT
KILL
REVOKE


关键字

epoch[ns,u,µ,ms,s,m,h]

设置时间显示格式,默认为UTC(2017-12-21T14:09:07.435Z), 添加epoch将显示为时间戳

使用

创建数据库

创建数据表

增添数据

+-----------+--------+-+---------+-+---------+
|measurement|,tag_set| |field_set| |timestamp|
+-----------+--------+-+---------+-+---------+
measurement :等同于table
tag_set     :列名,所有的tag都会被索引
field_set   :列名,不会被索引
timestamp   :时间戳,如果不传值,influxdb在写入该point的时候,会自动生成

//上面四个字段每一组都用“ ”分开
eg: insert Table,tag1=xx,tag2=xx,tag3=xx field1=xx,filed2=xx,filed3=xx timestamp

//tag_set无法单独查找tag_set列,可以单独查找field_set列
//官方原话:Note that you must specify at least one field in the `SELECT`
eg(error): select tag_set from Table
eg(correct): select field_set from Table
eg(correct): select tag_set,field_set from Table


修改数据

删除数据

查找数据

命令行

//根据时间排序,查找10条数据
select * from table order by time desc limit 10

//now(), 时间单位[ns,u,µ,ms,s,m,h]
select * from table where time>now()-1h


参考文档:https://yq.aliyun.com/articles/104243

Filter(过滤)

select * from table where cloumn0=’xx’ and cloumn1=’xx’

Aggregation(聚合) : SUM AVG Max TopN等

select avg(x) from table group by cloumn0

说明:group by 是基于相同时间粒度做聚合; pre-aggregation(预聚合,数据实时写入后就经过预聚合运算),提搞效率

Downsampling(降精度),Rollup(汇总)和Auto-rollup(自动汇总)

downsampling from interval(10) to interval(30), //10秒精度的数据聚合成30秒精度的数据
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: