**前置文章:**[Centos7.6安装Prometheus(普罗米修斯)监控](https://www.xiaoleizhang.com/index.php/archives/10/ "Centos7.6安装Prometheus(普罗米修斯)监控") **环境配置** |服务器|IP地址| | :------------: | :------------: | |Prometheus服务器|10.60.147.101| |被监控服务器|10.60.242.157| |grafana服务器|10.60.15.202| ------------ ------------ # 一、什么是Grafana Grafana是一个开源的度量分析和可视化工具,可以通过将采集的数据分析,查询,然后进行可视化的展示,并能实现报警。 网址: https://grafana.com/ # 二、安装配置Grafana ## 1、安装Grafana 在grafana服务器上安装grafana 下载地址:https://grafana.com/grafana/download ![Grafana下载.png](https://www.xiaoleizhang.com/usr/uploads/2021/11/1771796935.png) 我使用wget下载rpm包,也可以用官网的yum安装 ```shell wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.2.3-1.x86_64.rpm ``` ```shell [root@10-60-15-202 ~]# ll total 67804 -rw-r--r-- 1 root root 69430539 Nov 3 17:14 grafana-enterprise-8.2.3-1.x86_64.rpm [root@10-60-15-202 ~]# ``` 使用rpm -ivh安装rpm包 ```shell [root@10-60-15-202 ~]# rpm -ivh /root/grafana-enterprise-8.2.3-1.x86_64.rpm warning: /root/grafana-enterprise-8.2.3-1.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 24098cb6: NOKEY error: Failed dependencies: fontconfig is needed by grafana-enterprise-8.2.3-1.x86_64 urw-fonts is needed by grafana-enterprise-8.2.3-1.x86_64 [root@10-60-15-202 ~]# ``` 发现失败了,缺少组件,需要自己安装下组件,我这边就用yum安装组件了,然后再rpm安装就可以了 ```shell yum install -y fontconfig yum install -y urw-fonts ``` 启动服务 ```shell systemctl start grafana-server systemctl enable grafana-server ``` 确认端口(3000) ```shell [root@10-60-15-202 ~]# lsof -i:3000 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME grafana-s 5253 grafana 10u IPv6 87068 0t0 TCP *:hbci (LISTEN) [root@10-60-15-202 ~]# ``` 补充说明: lsof -i:端口号 加端口号,查看端口被谁占用 ## 2、登录Grafana 通过浏览器访问 `http://grafana服务器IP:3000`就到了登录界面,使用默认的admin用户,admin密码就可以登陆了 ![登陆Grafana.png](https://www.xiaoleizhang.com/usr/uploads/2021/11/4103900204.png) ## 3、添加数据源 下面我们把prometheus服务器收集的数据作为一个数据源添加到grafana,让grafana可以得到prometheus的数据。 ![Grafana增加数据源(1).png](https://www.xiaoleizhang.com/usr/uploads/2021/11/1316526443.png) ![Grafana增加数据源(2).png](https://www.xiaoleizhang.com/usr/uploads/2021/11/753239537.png) ![Grafana增加数据源(3).png](https://www.xiaoleizhang.com/usr/uploads/2021/11/2058077509.png) 然后就能看到Data sources ![Grafana增加数据源(4).png](https://www.xiaoleizhang.com/usr/uploads/2021/11/2825109539.png) ## 4、添加图形显示 为添加好的数据源做图形显示 可以使用模板套用,比较方便,我用的模板id是12633,进入下载地址后选择Download JSON然后下载下json文件。后面再进行Import 下载地址:https://grafana.com/grafana/dashboards/12633 ![Grafana图形显示(1).png](https://www.xiaoleizhang.com/usr/uploads/2021/11/1366500153.png) 上传好json文件后,你就会看到下图 ![Grafana图形显示(2).png](https://www.xiaoleizhang.com/usr/uploads/2021/11/3043338478.png) 然后你就能看到图形的监控界面了! ![Grafana图形显示(3).png](https://www.xiaoleizhang.com/usr/uploads/2021/11/1314130777.png) 最后修改:2022 年 01 月 09 日 © 允许规范转载 赞 0 如果觉得我的文章对你有用,请随意赞赏