Grafana是领先的开源可视化软件工具,无论您的数据在哪里,或者它所处的数据库是什么类型,您都可以将它与Grafana结合在一起,做成精美的可视化图表
Grafana官方手册
Grafana安装
上传Grafana安装包或者下载rpm安装包到服务器,执行如下命令安装:
1.配置yum源
(1)下载
[root@localhost ~]# wget https://dl.grafana.com/oss/release/grafana-6.7.2-1.x86_64.rpm
[root@localhost ~]# sudo yum install grafana-6.7.2-1.x86_64.rpm
(2)配置的本地的
[root@localhost ~]# cat /etc/yum.repos.d/grafana.repo
[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm-beta
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
[root@localhost ~]# sudo yum install grafana
3.启动grafana-server
[root@localhost ~]# systemctl start grafana-server
[root@localhost ~]# systemctl status grafana-server
[root@localhost ~]# systemctl enable grafana-server.service
[root@localhost ~]# netstat -ntlp | grep 3000
4.定义环境变量文件:/etc/sysconfig/grafana-server
/etc/sysconfig/grafana-server文件内容:不用修改
5.配置文件:/etc/grafana/grafana.ini 不用修改
Paths配置段
#################################### Paths ####################################
[paths]
# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
;data = /var/lib/grafana # 默认存放数据位置
# Temporary files in `data` directory older than given duration will be removed
;temp_data_lifetime = 24h
# 删除 'data'目录给定时间前的临时文件,使用0则不删除临时文件,时间格式h,m。如168h,30m,10h30m
# Directory where grafana can store logs
;logs = /var/log/grafana # grafana存储日志的目录
# Directory where grafana will automatically scan and look for plugins
;plugins = /var/lib/grafana/plugins # grafana存放插件的目录
# folder that contains provisioning config files that grafana will apply on startup and while running.
;provisioning = conf/provisioning
Server配置段
[server]
# Protocol (http, https, h2, socket)
;protocol = http #支持的协议
# The ip address to bind to, empty will bind to all interfaces
;http_addr = #服务监听的地址
# The http port to use
;http_port = 3000 #监听的端口
# The public facing domain name used to access grafana from a browser
;domain = localhost #使用域名访问服务
# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
;enforce_domain = false #是否 强制使用域名访问服务
# The full public facing url you use in browser, used for redirects and emails
# If you use reverse proxy and sub path specify full url (with sub path)
;root_url = %(protocol)s://%(domain)s:%(http_port)s/ #定义访问服务的路径
# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
;serve_from_sub_path = false
# Log web requests #是否记录web请求
;router_logging = false
# the path relative working path #定义静态文件的访问路径
;static_root_path = public
# enable gzip #是否开启压缩
;enable_gzip = false
# https certs & key file #证书文件
;cert_file =
;cert_key =
# Unix socket path #定义socket路径
;socket =
grafana默认存储数据采用的是sqlite3数据库,当然我们也可以使用mysql,这个需要在grafana配置文件中更改Database相关的配置即可
grafana的UI管理页面默认监听端口是3000,也可以通过修改配置文件server的相关配置即可
grafana默认登录的管理员账号密码都是:admin
改变默认登录 密码!,然后进入系统
添加数据源
添加zabbix 作为数据源
安装zabbix 插件
直接就跳到官网了
运行命令,安装插件
[root@localhost ~]# grafana-cli plugins install alexanderzobnin-zabbix-app
installing alexanderzobnin-zabbix-app @ 3.11.0
from url: https://grafana.com/api/plugins/alexanderzobnin-zabbix-app/versions/3.11.0/download
into: /var/lib/grafana/plugins
✔ Installed alexanderzobnin-zabbix-app successfully
Restart grafana after installing plugins . <service grafana-server restart>
重启服务
[root@localhost ~]# systemctl restart grafana-server
回到主页,开启zabbix app
再次添加zabbix作为数据源
http://192.168.88.99/zabbix/api_jsonrpc.php
zabbix的用户名:Admin
zabbix的密码:zabbix
导入数据
默认的仪表板
创建一个仪表盘
保存仪表盘
注意:务必要保证zabbix-server 和grafana server 这两台服务器的时间保持同步,否则 grafana server 是不会出图的!
yum -y install ntpdate
[root@localhost ~]# ntpdate 2.cn.pool.ntp.org
9 Mar 10:35:57 ntpdate[78871]: step time server 5.79.108.34 offset 2271639.199466 sec