1 Grafana是什么
Grafana是一个开源的度量分析和可视化工具,可以通过将采集的数据分析,查询,然后进行可视化的展示,并能实现报警。
2 安装Grafana
第一步:下载Grafana
官方下载地址:https://grafana.com/grafana/download
链接:https://pan.baidu.com/s/1ZuZ4nXlWqmQQnZQdMnprXA
提取码:xbqd
第二步:上传并安装
[root@localhost ~]# ls
anaconda-ks.cfg kafkaeagle 模板
apisix kafka-eagle 视频
data kibana-7.6.1-linux-x86_64.tar.gz 图片
docker-files logs 文档
elasticsearch-7.6.1-linux-x86_64.tar.gz logstash-7.16.2-linux-x86_64.tar.gz 下载
filebeat-6.5.4-linux-x86_64.tar.gz logstash-7.6.0.tar.gz 音乐
grafana-5.3.4-1.x86_64.rpm test_centos.tar 桌面
initial-setup-ks.cfg testjar
kafka 公共
[root@localhost ~]# mv grafana-5.3.4-1.x86_64.rpm /opt/prometheus/
[root@localhost ~]# cd /opt/prometheus/
[root@localhost prometheus]# ls
grafana-5.3.4-1.x86_64.rpm prometheus-2.6.1.linux-amd64 prometheus-2.6.1.linux-amd64.tar.gz
[root@localhost prometheus]# rpm -ivh grafana-5.3.4-1.x86_64.rpm
警告:grafana-5.3.4-1.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID 24098cb6: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:grafana-5.3.4-1 ################################# [100%]
### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server.service
### You can start grafana-server by executing
sudo /bin/systemctl start grafana-server.service
POSTTRANS: Running script
第三步:启动服务
[root@localhost prometheus]# systemctl start grafana-server
[root@localhost prometheus]# systemctl enable grafana-server
Created symlink from /etc/systemd/system/multi-user.target.wants/grafana-server.service to /usr/lib/systemd/system/grafana-server.service.
查看是否启动成功
[root@localhost prometheus]# lsof -i:3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
grafana-s 68257 grafana 6u IPv6 639958 0t0 TCP *:hbci (LISTEN)
[root@localhost prometheus]#
第四步:浏览器访问
通过浏览器访问 http:// grafana服务器IP:3000就到了登录界面,使用默认的admin用户,admin密码就可以登陆了
登录后的界面
3 Grafana连接Prometheus
第一步:添加数据源
把prometheus服务器收集的数据做为一个数据源添加到grafana,让grafana可以得到prometheus的数据。
第二步:设置数据源
设置数据源、数据源名称、类型、IP地址、端口号…
按如下填写
第三步:查看已添加的数据源
点击齿轮图标,查看已添加的数据源
第四步:为添加好的数据源做图形显示
为添加好的数据源做图形显示;
第一步:点击加号,选择dashboard
第二步:增加应该图形
第三步:点击编辑,选择需要呈现的数据
第四步:选择数据源和一些查询条件
通过pull指令,监控机器一分钟,五分钟和十五分钟的负载情况
第五步:保存
最后在dashboard可以查看到
第六步:匹配条件显示