时序列数据库之InfluxDB
Posted firsttry
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了时序列数据库之InfluxDB相关的知识,希望对你有一定的参考价值。
作为时序列数据库中表现很好的InfluxDB,已经被越来越多的项目应用到实际当中。比如资源的监控来说,Cadvisor监控到某一断面某一节点整体资源的状况,而且能够不断地从画面中看到不断变化的信息,但是这些数据如何持久化的保存是一个问题,而InfluxDB正好可以满足这个需求,其简单好用,耦合度小,容易集成到整体的系统之中。
Docker pull
[[email protected] ~]# docker pull docker.io/influxdb
Docker run
使用这种方式便于观察InfluxDB的HTTP API如何具体执行,并且可以看到更加详细的一些信息。
docker run -p 8083:8083 -p 8086:8086 influxdb
[[email protected] ~]# docker run -p 8083:8083 -p 8086:8086 influxdb
8888888 .d888 888 8888888b. 888888b.
888 d88P" 888 888 "Y88b 888 "88b
888 888 888 888 888 888 .88P
888 88888b. 888888 888 888 888 888 888 888 888 8888888K.
888 888 "88b 888 888 888 888 Y8bd8P‘ 888 888 888 "Y88b
888 888 888 888 888 888 888 X88K 888 888 888 888
888 888 888 888 888 Y88b 888 .d8""8b. 888 .d88P 888 d88P
8888888 888 888 888 888 "Y88888 888 888 8888888P" 8888888P"
[run] 2016/08/02 22:19:47 InfluxDB starting, version 0.13.0, branch 0.13, commit e57fb88a051ee40fd9277094345fbd47bb4783ce
[run] 2016/08/02 22:19:47 Go version go1.6.2, GOMAXPROCS set to 1
[run] 2016/08/02 22:19:47 Using configuration at: /etc/influxdb/influxdb.conf
[store] 2016/08/02 22:19:47 Using data dir: /var/lib/influxdb/data
[subscriber] 2016/08/02 22:19:47 opened service
[monitor] 2016/08/02 22:19:47 Starting monitor system
[monitor] 2016/08/02 22:19:47 ‘build‘ registered for diagnostics monitoring
[monitor] 2016/08/02 22:19:47 ‘runtime‘ registered for diagnostics monitoring
[monitor] 2016/08/02 22:19:47 ‘network‘ registered for diagnostics monitoring
[monitor] 2016/08/02 22:19:47 ‘system‘ registered for diagnostics monitoring
[cluster] 2016/08/02 22:19:47 Starting cluster service
[shard-precreation] 2016/08/02 22:19:47 Starting precreation service with check interval of 10m0s, advance period of 30m0s
[snapshot] 2016/08/02 22:19:47 Starting snapshot service
[copier] 2016/08/02 22:19:47 Starting copier service
[admin] 2016/08/02 22:19:47 Starting admin service
[admin] 2016/08/02 22:19:47 Listening on HTTP: [::]:8083
[continuous_querier] 2016/08/02 22:19:47 Starting continuous query service
[httpd] 2016/08/02 22:19:47 Starting HTTP service
[httpd] 2016/08/02 22:19:47 Authentication enabled: false
[httpd] 2016/08/02 22:19:47 Listening on HTTP: [::]:8086
[retention] 2016/08/02 22:19:47 Starting retention policy enforcement service with check interval of 30m0s
[run] 2016/08/02 22:19:47 Listening for signals
[monitor] 2016/08/02 22:19:47 Storing statistics in database ‘_internal‘ retention policy ‘monitor‘, at interval 10s
2016/08/02 22:19:47 Sending anonymous usage statistics to m.influxdb.com
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
画面确认
Influxdb的HTTP API
创建DB
[root@host31 ~]# curl -i -XPOST http://192.168.32.31:8086/query --data-urlencode "q=CREATE DATABASE mydb"
HTTP/1.1 200 OK
Connection: close
Content-Type: application/json
Request-Id: 42a1f30c-5900-11e6-8003-000000000000
X-Influxdb-Version: 0.13.0
Date: Tue, 02 Aug 2016 22:27:13 GMT
Content-Length: 16
{"results":[{}]}[root@host31 ~]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
写入数据
[root@host31 ~]# curl -i -XPOST ‘http://192.168.32.31:8086/write?db=mydb‘ --data-binary ‘cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000‘
HTTP/1.1 204 No Content
Request-Id: c2fdbba7-5900-11e6-8006-000000000000
X-Influxdb-Version: 0.13.0
Date: Tue, 02 Aug 2016 22:30:48 GMT
[root@host31 ~]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
查询写入的数据
[[email protected] ~]# curl -GET ‘http://192.168.32.31:8086/query?pretty=true‘ --data-urlencode "db=mydb" --data-urlencode "q=SELECT "value" FROM "cpu_load_short" WHERE "region"=‘us-west‘"
{
"results": [
{
"series": [
{
"name": "cpu_load_short",
"columns": [
"time",
"value"
],
"values": [
[
"2015-06-11T20:46:02Z",
0.64
]
]
}
]
}
]
}[[email protected] ~]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
以上是关于时序列数据库之InfluxDB的主要内容,如果未能解决你的问题,请参考以下文章
C3.js - 如何在绘制取自 InfluxDB 的时间序列时指定时间戳格式