一个相似Kibana的东西,也是对后端的数据进行实时展现,那么Grafana和Kibana有什么区别?在我看来区别不大,不过在你们的平常使用中Kibana是跟着Logstash、ElasticSearch等组件一块儿使用作日志展现、索引、分析的,形成了一种假象就是Kibana就只有这种用法了,Kibana也能够接入其余数据源的,不过你们最长用的仍是展现日志。html
那么Grafana究竟是什么呢?Grafana其实就是一个可视化面板(Dashboard),有着很是漂亮的图表和布局展现,功能齐全的度量仪表盘和图形编辑器,支持Graphite、zabbix、InfluxDB、Prometheus和OpenTSDB做为数据源。随着版本的迭代,支持接入的数据源将会更多。git
下面看看官方是怎么解释Grafana的:github
grafana是用于可视化大型测量数据的开源程序,他提供了强大和优雅的方式去建立、共享、浏览数据。dashboard中显示了你不一样metric数据源中的数据。web
grafana最经常使用于因特网基础设施和应用分析,但在其余领域也有机会用到,好比:工业传感器、家庭自动化、过程控制等等。 redis
grafana有热插拔控制面板和可扩展的数据源,目前已经支持Graphite、InfluxDB、OpenTSDB、Elasticsearch。json
Grafana官方网站:https://grafana.com/ 后端
访问Grafana下载页面https://grafana.com/grafana/download在这里可获取该软件的全版本。api
能够按照使用需求,进行下载相应版本。浏览器
[root@monitor.clsn.io /root] #cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) [root@monitor.clsn.io /root] #uname -r 3.10.0-862.el7.x86_64 [root@monitor.clsn.io /root] #systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1) [root@monitor.clsn.io /root] #sestatus SELinux status: disabled
在此次安装中,咱们使用的是grafana-5.2.4版本。不一样版本之间功能存在着必定的差距。服务器
[root@monitor.clsn.io /root] #wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.4-1.x86_64.rpm [root@monitor.clsn.io /root] #ls grafana-5.2.4-1.x86_64.rpm [root@monitor.clsn.io /root] #sudo yum localinstall grafana-5.2.4-1.x86_64.rpm
[root@monitor.clsn.io /root] #systemctl start grafana-server.service [root@monitor.clsn.io /root] #systemctl enable grafana-server.service
Grafana默认监听端口为3000,能够经过修改配置文件(/etc/grafana/grafana.ini)对其作定制化配置。
[root@monitor.clsn.io /root] #netstat -lntup |grep grafana tcp6 0 0 :::3000 :::* LISTEN 1333/grafana-server
经过流量器访问 http://ip:3000 便可访问grafana页面,初始用户名与密码均为admin,可在登录是修改默认密码。
登录成功以后能够先进行建立第一个数据源,以及第一个展现面板。
使用Zabbix收集数据,Grafana展现图形,许多的公司都是这么作的。Grafana默认没有zabbix做为数据源,咱们须要手动给zabbix安装一个插件,而后再添加进Grafana便可。
关于zabbix的安装能够参照如下文章进行配置。
惨绿少年博客:http://www.javashuo.com/article/p-tsgzrpxb-nb.html
zabbix官方文档:https://www.zabbix.com/documentation/3.4/zh/manual
注:本次使用zabbix版本为3.4.14。
[root@monitor.clsn.io /root] #zabbix_server -V zabbix_server (Zabbix) 3.4.14 Revision 84877 14 September 2018, compilation time: Sep 14 2018 08:09:35 Copyright (C) 2018 Zabbix SIA License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it according to the license. There is NO WARRANTY, to the extent permitted by law.
经过grafana-cli plugins list-remote命令 能够获取到grafana的插件列表。
[root@monitor.clsn.io /root] #grafana-cli plugins list-remote |grep zabbix id: alexanderzobnin-zabbix-app version: 3.9.1
从上能够查询到插件版本为3.9.1
安装插件
[root@monitor.clsn.io /root] #grafana-cli plugins install alexanderzobnin-zabbix-app installing alexanderzobnin-zabbix-app @ 3.9.1 from url: https://grafana.com/api/plugins/alexanderzobnin-zabbix-app/versions/3.9.1/download into: /var/lib/grafana/plugins ✔ Installed alexanderzobnin-zabbix-app successfully Restart grafana after installing plugins . <service grafana-server restart>
出现√即为安装成功。在安装完成后无比重启grafana使其生效。
[root@monitor.clsn.io /root] #systemctl restart grafana-server.service
登录grafana页面,开启zabbix插件。
点击enable开启插件。
添加zabbix数据源
相关配置项目说明:
配置项目 |
说明 |
Name |
给数据源起一个名字。 |
Default |
选择默认,意味着数据源将预先选定为新的面板。 |
Type |
选择数据源的类型。 |
Url |
这里的Url是http协议,地址和端口是zabbix-web提供的接口。或为zabbix的api地址。 |
Access |
访问代理,这里选择了proxy表示Grfana经过后端访问,还有direct值表示从浏览器直接访问目录。 |
Username |
输入zabbix的用户名,须要进行认证,通常使用管理员。 |
Password |
输入zabbix用户的密码。 |
代理(proxy)访问意味着的Grafana后端将从浏览器代理全部请求,并将它们发送到数据源。这样是有用的,由于它能够消除CORS(交叉来源站点资源)的问题,如消除须要传播到数据源到浏览器的身份验证详细信息。但还支持直接(direct)访问,由于在某些状况下可能用来访问直接根据用例和拓扑结构的Grafana、 用户和数据源的数据源。
以上信息都填写完成以后点击Save & Test,通常只要看见Success就表示成功了,下面就能够去利用zabbix中数据添加图形了。
下面先引入zabbix自带的dashboard,点击import。
使用grafana的好处是对图形的自定义更加简便,经过变动不一样的json文件,便可在数据源中查找到想要的结果,而后绘制出图。
安装插件最简单的方法是使用与grafana捆绑在一块儿的CLI工具grafana-cli。在修改插件以后发生任何修改以前,grafana服务器须要从新启动。
Grafana插件安装目录
在Linux系统上,grafana-cli会假定grafana插件目录是/var/lib/grafana/plugins。经过指定-pluginsDir标志能够覆盖grafana-cli将要运行的目录。在Windows系统中,必须为每一个呼叫指定此参数
Grafana-cli命令说明
列出可用的插件 #grafana-cli plugins list-remote 安装最新版本的插件 #grafana-cli plugins install <plugin-id> 安装特定版本的插件 #grafana-cli plugins install <plugin-id> <version> 列出安装的插件 #grafana-cli plugins ls 更新全部安装的插件 #grafana-cli plugins update-all 更新一个插件 #grafana-cli plugins update <plugin-id> 删除一个插件 #grafana-cli plugins remove <plugin-id>
[1] http://www.javashuo.com/article/p-tsgzrpxb-nb.html
[2] http://www.ywnds.com/?cat=122
[3] https://github.com/grafana/grafana/
[4] https://grafana.com/grafana/download