influxDB和grafana
influxdb启动服务
sudo service influxdb start
登录数据库
influx
在influxDB中,measurement相当于sql中的table, 插入measurement时,tags之间用,分割,fiels之间用,分割,tags和field用空格分开
HTTP API
创建一个database
curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb2"
向数据库中写入数据
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
如果写入多条数据,每一行输入一条
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server02 value=0.67 cpu_load_short,host=server02,region=us-west value=0.55 1422568543702900257 cpu_load_short,direction=in,host=server01,region=us-west value=2.0 1422568543702900257'
从数据库中读取数据
curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=mydb" --data-urlencode "q=SELECT value FROM cpu_load_short WHERE region='us-west'"
如果读取多个数据,每个查询语句用分号分开
curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=mydb" --data-urlencode "q=SELECT value FROM cpu_load_short WHERE region='us-west';SELECT count(value) FROM cpu_load_short WHERE region='us-west'"
启动grafana服务:
sudo service grafana-server start