隨著業務的越發復雜,對軟體系統的要求越來越高,這意味著我們需要隨時掌控系統的運行情況,因此,對系統的實時監控以及可視化展示,就成了基礎架構的必須能力,
Grafana官方網站
https://grafana.com/
Grafana介紹
Grafana是一個跨平臺的開源的度量分析和可視化工具,可以通過將采集的資料查詢然后可視化的展示,并及時通知,它主要有以下六大特點:
1、展示方式:快速靈活的客戶端圖表,面板插件有許多不同方式的可視化指標和日志,官方庫中具有豐富的儀表盤插件,比如熱圖、折線圖、圖表等多種展示方式;
2、資料源:zabbix,Graphite,InfluxDB,OpenTSDB,Elasticsearch,CloudWatch和KairosDB等;
3、通知提醒:以可視方式定義最重要指標的警報規則,Grafana將不斷計算并發送通知,在資料達到閾值時通過Slack、PagerDuty等獲得通知;
4、混合展示:在同一圖表中混合使用不同的資料源,可以基于每個查詢指定資料源,甚至自定義資料源;
5、注釋:使用來自不同資料源的豐富事件注釋圖表,將滑鼠懸停在事件上會顯示完整的事件元資料和標記;
6、過濾器:Ad-hoc過濾器允許動態創建新的鍵/值過濾器,這些過濾器會自動應用于使用該資料源的所有查詢,
下載安裝
本文這次介紹 zabbix與 Grafana結合使用
首先 先安裝好zabbix 配置完成后開始安裝Grafana
zabbix官網
https://www.zabbix.com/
Grafana官網
https://grafana.com/
zabbix安裝這次不再贅述 沒安裝的可以看我之前的博客
獲取Grafana
訪問Grafana下載頁面https://grafana.com/grafana/download在這里可獲取該軟體的全版本,
可以按照使用需求,進行下載相應版本,
安裝Grafana
系統環境說明
[root@centos /root]
#cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@centos /root]
#uname -r
3.10.0-862.el7.x86_64
[root@centos /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@centos /root]
#sestatus
SELinux status: disabled
安裝Grafana
在這次安裝中,我們使用的是grafana-5.2.4版本,不同版本之間功能存在著一定的差距,
[root@centos /root]
#wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.4-1.x86_64.rpm
[root@centos /root]
#yum install initscripts fontconfig #安裝依賴
grafana-5.2.4-1.x86_64.rpm
[root@centos /root]
#yum localinstall grafana-5.2.4-1.x86_64.rpm
啟動Grafana
[root@centos /root]
#systemctl start grafana-server.service
[root@centos /root]
#systemctl enable grafana-server.service
檢查監聽埠
Grafana默認監聽埠為3000,可以通過修改組態檔(/etc/grafana/grafana.ini)對其做定制化配置,
[root@centos /root]
#netstat -lntup |grep grafana
tcp6 0 0 :::3000 :::* LISTEN 1333/grafana-server
Grafana的使用
訪問界面
通過流量器訪問 http://ip:3000 即可訪問grafana頁面,初始用戶名與密碼均為admin,可在登陸是修改默認密碼,
登陸成功之后可以先進行創建第一個資料源,以及第一個展示面板,
Grafana For Zabbix
使用Zabbix收集資料,Grafana展示圖形,Grafana默認沒有zabbix作為資料源,需要給zabbix安裝一個插件,然后再添加進Grafana即可,
注:本次使用zabbix版本為3.4.14,
[root@centos /root]
#zabbix_server -V
zabbix_server (Zabbix) 3.4.14
獲取zabbix 插件
通過grafana-cli plugins list-remote命令 可以獲取到grafana的插件串列,
[root@centos /root]
#grafana-cli plugins list-remote |grep zabbix
id: alexanderzobnin-zabbix-app version: 3.9.1
安裝插件
[root@centos /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@centos /root]
#systemctl restart grafana-server.service
配置zabbix源
登陸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,
查看zabbix dashboard頁面
使用grafana的好處是對圖形的自定義更加簡便,通過變更不同的json檔案,即可在資料源中查找到想要的結果,然后繪制出圖,
Grafana相關補充
Grafana插件安裝目錄
在Linux系統上,grafana-cli會假定grafana插件目錄是/var/lib/grafana/plugins,通過指定-pluginsDir標志可以覆寫grafana-cli將要運行的目錄,在Windows系統中,必須為每個呼叫指定此引數
Grafana-cli命令說明
安裝插件最簡單的方法是使用與grafana捆綁在一起的CLI工具grafana-cli,在修改插件之后發生任何修改之前,grafana服務器需要重新啟動,
列出可用的插件
#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>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/141626.html
標籤:Linux
上一篇:shell基礎
下一篇:LAMP環境搭建+配置虛擬域名
