prometheus是一个时序数据库,存数据
export 是收集器,来收集被监控的数据,想要监控不同的内容,就使用不同的export,这个export应该放在 被测服务器上
然后,再把export与prometheus进行关联(数据联通),这个解决方案,可以用于运维人员来监控服务器。
一 、grafana安装安装
命令一:rpm -ivh grafana-7.4.3-1.x86_64.rpm
命令二:yum install grafana-7.4.3-1.x86_64.rpm
启动命令:systemctl restart grafana-server
查看grafana启动的进程 ps -ef |grep grafana
访问地址:http://192.168.232.137:3000/ 账号密码:admin/admin
二、exporter安装 2.1、node_export上传到 被测服务器上,解压文件;tar -xzvf node_exporter-1.1.1.linux-amd64.tar.gz
ls -l 查看文件类型,d开头的是文件夹,-开头的是可执行文件
cd 进入解压的文件夹cd node_exporter-1.1.1.linux-amd64
可执行文件不知道用,命令后面跟着 --help,./node_exporter --help
2.2、执行命令:nohup ./node_exporter &把命令后台执行,同时把运行日志,写到nohup.out文件中
查看日志文件 vim nohup.out ,
可知道node_export 端口:9100 ------被测服务器 需要开放9100端口
2.3、查看node_export是否启动正常YouExportIP+端口地址:http://192.168.232.134:9100/metrics ,这个能访问说明,是正常的/ 网络也是可以被访问的
三、prometheus安装 3.1把prometheus的包,放在非被测服务器解压: tar -xzvf prometheus-2.20.1.linux-amd64.tar.gz
进入解压后的文件夹 cd prometheus-2.20.1.linux-amd64
通过日志,我们发现 prometheus.yml是它的配置文件
3.2、查看prometheus是否启动正常的网址可以通过 ip访问prometheus的界面:http://192.168.0.103:9090/
四、prometheus 与 exporter 集成 4.1、修改:prometheus.yml 文件注意:yml文件语法: 缩进(对齐),key 的冒号后面,有一个空格
- job_name: 'node_exporter'
static_configs:
- targets: ['192.168.232.134:9100'] 写法一
- targets: ['192.168.232.134:9100','192.168.232.134:9100'] 有多个ip用英文逗号分开 写法二
4.2启动查看是否写配置文件正确启动命令:nohup ./prometheus &
查看日志是否正确启动:vim nohup.out
level=info ts=2022-03-03T04:19:12.593Z caller=main.go:833 msg="Completed loading of configuration file" filename=prometheus.yml
level=info ts=2022-03-03T04:19:12.593Z caller=main.go:652 msg="Server is ready to receive web requests."
说明是配置文件没有问题
Start listening for connections" address=0.0.0.0:9090 可查看到 prometheus的端口:9090
五、grafana的界面中配置 5.1、添加prometheus 数据源:type选择 prometheus 、URL:http://192.168.0.103:90905.2、引入模板
可登录网址:Dashboards | Grafana Labs 搜索模板
这里引入的是:12884
常见的问题:1、监控平台机器 和 被测试服务器 在不同的机器上,这两台机器间的时间差
如果在监控平台上,看不到数据,可以去修改右上角的时间范围为 大于8小时
2、监控界面中 JOB 、 instance没有
你的yml配置文件问题、数据源配置有问题、import模板的时候你的数据源选择上有问题。
3、note_exporter ,grafana 和prometheus 没有启动成功
note_exporter启动校验网址:http://192.168.232.134:9100/metrics
grafana校验网址:http://192.168.232.137:3000/
prometheus校验网址:http://192.168.232.137:9090/
4、VM两个虚拟机的网络适配器的 网络连接:NAT模式



