欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
InfluxDB
来自开放百科 - 灰狐
InfluxDB 是一个 Go 语言开发的开源(MIT)分布式时间序列数据库。
目录 |
TICK堆栈
- Telegraf 数据采集
- InfluxDB 数据存储
- Chronograf 数据可视化
- Kapacitor 监控告警&ETL
应用场景
- 定制DevOps监控(Custom DevOps Monitoring)
- 实时分析(Real Time Analytics)
- 物联网和传感器数据(IoT and Sensor Data)
- 云计算(Cloud & OpenStack)
- 异常检测(Anomaly Detection)
- 消息(Messaging)
- 个性化(Personalization)
- 股票交易(Equities Trading)
- 市政基础设施管理(Municipal Infrastructure Management)
- GPS服务(GPS Services)
- 量子物理研究(Quantum Physics Research)
- POS系统(Point of Sale Systems)
- 制造业和家庭自动化(Manufacturing & Home Automation)
- 运输和物流(Transportation & Material Logistics)
指南
OS X 安装
$ brew update $ brew install influxdb $ brew install telegraf // 数据采集 $ brew install homebrew/binary/chronograf // 数据可视化 $ brew install kapacitor // 告警、数据处理 $ influxd $ influx Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring. Connected to http://localhost:8086 version 0.9.6.1 InfluxDB shell 0.9.6.1 > create database mydb > show databases > use mydb > insert cpu,host=serverA,region=us_west value=0.64 > select * from cpu > insert temperature,machine=unit42,type=assembly external=25,internal=37 > select * from temperature > show series > show measurements > show tag keys > show field keys
创建数据库
curl -G 'http://localhost:8086/query' --data-urlencode "q=CREATE DATABASE mydb"
插入数据
curl -XPOST 'http://localhost:8086/write?db=mydb' -d 'cpu,host=server01,region=uswest load=42 1434055562000000000' curl -XPOST 'http://localhost:8086/write?db=mydb' -d 'cpu,host=server02,region=uswest load=78 1434055562000000000' curl -XPOST 'http://localhost:8086/write?db=mydb'-d 'cpu,host=server03,region=useast load=15.4 1434055562000000000'
查询数据
curl -G http://localhost:8086/query?pretty=true --data-urlencode "db=mydb" --data-urlencode "q=SELECT * FROM cpu WHERE host='server01' AND time < now() - 1d"
分析数据
curl -G http://localhost:8086/query?pretty=true --data-urlencode "db=mydb" --data-urlencode "q=SELECT mean(load) FROM cpu WHERE region='uswest'"
sample数据集
curl https://s3-us-west-1.amazonaws.com/noaa.water.database.0.9/NOAA_data.txt > sample-data.txt influx -import -path=sample-data.txt -precision=s
提示信息: 2016/02/23 10:32:35 Processed 76290 inserts
> use NOAA_water_database > show measurements > select count(water_level) from h2o_feet > select * from h2o_feet limit 5
Web管理接口
http://localhost:8083/
Grafana
Grafana 是面向 Graphite, InfluxDB & OpenTSDB 可视化仪表盘。
Telegraf
Telegraf数据采集,一个插件驱动的服务器代理。
$ telegraf --help $ telegraf -sample-config -input-filter cpu -output-filter influxdb
Chronograf
$ Chronograf http://127.0.0.1:10000
Kapacitor
启动Kapacitor
kapacitord config > kapacitor.conf kapacitord -config kapacitor.conf http://localhost:9092/
Kapacitor 使用 TICKscript DSL 来定义任务(tasks)。
如:cpu_alert.tick
stream // 从sample数据库获得cpu测量值 .from().measurement('cpu') .alert() .crit(lambda: "usage_idle" < 70) // 写入日志文件 .log('/tmp/alerts.log')
写入task
kapacitor define \ -name cpu_alert \ -type stream \ -tick cpu_alert.tick \ -dbrp mydb.default
运行task
kapacitor record stream -name cpu_alert -duration 20s
获得数据
kapacitor list recordings $rid
返回类似数据
ID Type Size Created 32bc3657-4a96-472e-a982-11afc1bfb51a stream 0 B 23 Feb 16 17:42 CST ff90d6c3-f4a5-441c-b69d-7b23ee753398 stream 0 B 23 Feb 16 17:48 CST
Kapacitor控制台返回类似数据
[httpd] 2016/02/23 17:49:57 I! ::1 - - [23/Feb/2016:17:49:57 +0800] GET /recordings?rids= HTTP/1.1 200 173 - Go-http-client/1.1 cc17e978-da12-11e5-8019-000000000000 362.8µs [httpd] 2016/02/23 17:50:10 I! ::1 - - [23/Feb/2016:17:50:10 +0800] GET /recordings?rids= HTTP/1.1 200 173 - Go-http-client/1.1 d42f803b-da12-11e5-801a-000000000000 1.570713ms [httpd] 2016/02/23 17:50:30 I! ::1 - - [23/Feb/2016:17:50:30 +0800] GET /recordings?rids= HTTP/1.1 200 173 - Go-http-client/1.1 dfc64c93-da12-11e5-801b-000000000000 1.266153ms
图集
链接
分享您的观点