Grafana部署

齐意致
2023-12-01

grafana 是一款采用 go 语言编写的开源应用,主要用于大规模指标数据的可视化展现,是网络架构和应用分析中最流行的时序数据展示工具,目前已经支持绝大部分常用的时序数据库。

官网:https://grafana.com/


  • yum安装grafana:
vim /etc/yum.repos.d/grafana.repo
[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
yum makecache fast

yum install -y grafana

systemctl daemon-reload

systemctl enable grafana-server && systemctl start grafana-server

grafana-cli plugins install alexanderzobnin-zabbix-app              #安装zabbix插件

systemctl restart grafana-server

初始账号密码为adminadmin,建议后面更改密码。

grafana配置文件:/etc/grafana/grafana.ini

  • rpm安装grafana:
cd /software

wget https://mirrors.tuna.tsinghua.edu.cn/grafana/yum/rpm/grafana-6.7.2-1.x86_64.rpm

yum install -y initscripts urw-fonts

rpm -Uvh grafana-6.7.2-1.x86_64.rpm
systemctl daemon-reload

systemctl enable grafana-server && systemctl start grafana-server

grafana-cli plugins install alexanderzobnin-zabbix-app              #安装zabbix插件

systemctl restart grafana-server

初始账号密码为adminadmin,建议后面更改密码。

grafana配置文件:/etc/grafana/grafana.ini


  • docker部署grafana:
mkdir /home/grafana && chmod 777 /home/grafana

docker pull grafana/grafana

docker run -d -p 3000:3000 --name=grafana -v /home/grafana:/var/lib/grafana grafana/grafana

docker exec -it grafana grafana-cli plugins install alexanderzobnin-zabbix-app              #安装zabbix插件

docker restart grafana

初始账号密码为adminadmin,建议后面更改密码。

grafana容器配置文件:/etc/grafana/grafana.ini


  • 配置zabbix数据源:

ConfigurationPluginsZabbixEnable

Add data sourceZabbixURL(http://zabbix_server_ip/zabbix/api_jsonrpc.php)UsernamePasswordTrends(true)

这里设置URL可能会报错:Could not connect to given url,建议多尝试,最好带zabbix的httpd监听端口,我这里是http://192.168.1.252:8081/zabbix/api_jsonrpc.php


  • 安装插件:

grafana所有插件:https://grafana.com/grafana/plugins?orderBy=weight&direction=asc

grafana-cli plugins install grafana-clock-panel             #时钟

grafana-cli plugins install kentik-app              #网络流量

grafana-cli plugins install grafana-piechart-panel              #饼图

grafana-cli plugins install novalabs-annotations-panel              #注释

grafana-cli plugins install farski-blendstat-panel              #混合

grafana-cli plugins install yesoreyeram-boomtable-panel             #多表

grafana-cli plugins install yesoreyeram-boomtheme-panel             #多主题

grafana-cli plugins install jeanbaptistewatenberg-percent-panel             #百分比

grafana-cli plugins install corpglory-progresslist-panel                #进程列表

grafana-cli plugins install mxswat-separator-panel              #分隔符 |

grafana-cli plugins install aidanmountford-html-panel               #网页

安装完插件需要重启grafana:systemctl restart grafana-server


  • 监控主机是否存活:

grafana与zabbix结合时,zabbix的agent.ping无法准确反映主机是否宕机。因此,需要使用icmpping[<target>,<packets>,<interval>,<size>,<timeout>]来监控是否存活,存活返回1,反之返回0。


 类似资料: