時序列數據庫之InfluxDB
阿新 • • 發佈:2019-01-20
整體 pro from sql style 持久化 並且 ons name
作為時序列數據庫中表現很好的InfluxDB,已經被越來越多的項目應用到實際當中。比如資源的監控來說,Cadvisor監控到某一斷面某一節點整體資源的狀況,而且能夠不斷地從畫面中看到不斷變化的信息,但是這些數據如何持久化的保存是一個問題,而InfluxDB正好可以滿足這個需求,其簡單好用,耦合度小,容易集成到整體的系統之中。
Docker pull
[root@host31 ~]# docker pull docker.io/influxdb
Docker run
使用這種方式便於觀察InfluxDB的HTTP API如何具體執行,並且可以看到更加詳細的一些信息。
docker run -p 8083:8083 -p 8086:8086 influxdb
[root@host31 ~]# 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
查詢寫入的數據
[root@host31 ~]# 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
]
]
}
]
}
]
}[root@host31 ~]#
- 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