通用技术 数据可视化之 Grafana-Table Panel

胡刚 · 2016年04月01日 · 2477 次阅读

1.背景

传统的数据可视化工具展示的都是折线图,是否有一种更直观的方式,去展示数据;本文将介绍 Grafana 的 Table Panel,将数据用表格展示,当数据在不同数值区间内,会使用不同颜色填充表格,能迅速的判断当前数据的状态。

2.实现

数据可视化:
Grafana:https://github.com/grafana/grafana(golang 1.5,NodeJS 需自行安装)

数据源:
InfluxDB

2-1.安装数据源

Grafana 支持的数据源有:Graphite,Elasticsearch,CloudWatch,InfluxDB,OpenTSDB,KairosDB,Prometheus。

本文使用 InfluxDB:时序化的数据库

An open source time-series database designed for high-performance writes and compact disk storage. Supports open source high-availability architectures and native clustering is available through an Influx Enterprise subscription.

安装 wiki:https://influxdata.com/downloads/

InfluxDB 默认使用的端口:

TCP port 8083 is used for InfluxDB’s Admin panel;

TCP port 8086 is used for client-server communication over InfluxDB’s HTTP API;
TCP ports 8088 and 8091 are required for clustered InfluxDB instances

如果你想自定义端口,需修改配置文件:/etc/influxdb/influxdb.conf

在 centos 下实例:


cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL \$releasever
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOF
sudo yum install influxdb
sudo service influxdb start


[root@10 suite]# service influxdb start
Starting the process influxdb [ OK ]
influxdb process was started [ OK ]

命令行操作 DB:

[root@10 suite]# influx -port 28086
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:28086 version 0.11.0
InfluxDB shell 0.11.0
>

HTTP API 操作 DB:

具体请参考:https://docs.influxdata.com/influxdb/v0.9/guides/writing_data/
比如写数据:

curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'

定时任务写数据到 InfluxDB。

2-2.安装 Grafana

最新版本是 3.0 beta, 由于还是公测版,选择稳定版 Grafana v2.6.0,下载地址:http://grafana.org/download/

依赖 GO 及 NodeJS, 自行安装;

centos 下实例:

$ sudo yum install initscripts fontconfig
$ sudo rpm -Uvh grafana-2.6.0-1.x86_64.rpm

启动服务:

sudo service grafana-server start

访问:10.13.1.139:3000

账号:admin/admin

2-3. 配置 Grafana

配置数据源:

这里写图片描述

在 dashboard 中,新加行 “+ADD ROW”
配置如下:
这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

结果如下:

这里写图片描述

数据统计结果展示

新建一行,配置如下:
这里写图片描述

结果如下:
这里写图片描述

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册