Grafana是領先的開源可視化軟件工具,無論您的數據在哪里,或者它所處的數據庫是什么類型,您都可以將它與Grafana結合在一起,做成精美的可視化圖表
Grafana官網:https://grafana.com/
Grafana官方手冊:https://grafana.com/docs/
Grafana安裝
上傳Grafana安裝包或者下載rpm安裝包到服務器,執行如下命令安裝:
配置yum源
Add the following to a new file at /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
sudo yum install grafana
啟動grafana-server
systemctl start grafana-server systemctl status grafana-serversystemctl enable grafana-server.service
定義環境變量文件:/etc/sysconfig/grafana-server
/etc/sysconfig/grafana-server文件內容:不用修改
配置文件:/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@node1 ~]# grafana-cli plugins install alexanderzobnin-zabbix-app installing alexanderzobnin-zabbix-app @ 3.10.4 from: https://grafana.com/api/plugins/alexanderzobnin-zabbix-app/versions/3.10.4/download into: /var/lib/grafana/plugins ✔ Installed alexanderzobnin-zabbix-app successfully Restart grafana after installing plugins . <service grafana-server restart>
重啟服務
systemctl restart grafana-server.service
回到主頁,開啟zabbix app


再次添加zabbix作為數據源

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
