Fork me on GitHub

目录:

Grafana是一个优秀的开源图表系统,支持多种数据源,其中包括 InfluxDBPrometheus

安装

export GOPATH=`pwd`
go get github.com/grafana/grafana
cd $GOPATH/src/github.com/grafana/grafana
go run build.go setup              # (only needed once to install godep)
$GOPATH/bin/godep restore          # (will pull down all golang lib dependencies in your current GOPATH)
go run build.go build              # (or 'go build .')

编译好后会在bin目录下生成grafana-servergrafana-cli

第二步需要生成资源文件,但是从源代码编译会遇到phantomjs-prebuild依赖包不存在arm版本的问题,可以直接下载windows版本解开里面的public目录到bin/public下

启动

在bin/conf下拷贝生成defaults.ini文件,执行./grafana-server即可

配置

用浏览器打开 http://<pi:ip>:3000 用帐号:admin,密码:admin 登录

首先要配置好Prometheus数据源:

下面是获取网络的上下行流量数据的采集脚本,通过Prometheus Push Gateway提交,可以每5分钟运行一次

DATA=`ifconfig eth1 | grep bytes | sed 's/:/ /g' | awk '{print "bytes_rx "$3"\nbytes_tx "$8}'`
cat <<EOF | curl --data-binary @- http://pi3:9091/metrics/job/raspberrypi/instance/test
$DATA
EOF

然后在Grafana里可以按下图方式增加一个每小时网络流量的图表,increase(bytes_rx[1h])Prometheus所支持的查询表达式。



blog comments powered by Disqus

Published

2016-04-24

Categories


Tags