prometheus+grafana分布式集群资源监控体系搭建
- 前言
- 一、安装 prometheus
- 二、在要监控的服务器上安装监听器
- 三、prometheus服务器配置
- 四、grafana配置大屏
- 五、创建Linux监控看板
- 五、监控windows服务器
- 注意事项
前言
Prometheus 是一个开源的 分布式监控系统 和 时间序列数据库,最初由 SoundCloud 开发,现由云原生计算基金会(CNCF)维护。它专为 高动态环境(如微服务架构、云原生应用)设计,专注于 实时数据采集、存储、查询和报警,广泛应用于 DevOps 和基础设施监控领域。
一、安装 prometheus
文件获取:prometheus-2.36.1.linux-amd64.tar.gz
解压:tar -zxvf prometheus-2.36.1.linux-amd64.tar.gz
后台启动:
cd prometheus-2.36.1.linux-amd64
nohup ./prometheus --config.file=prometheus.yml > prom.log 2>&1 &
web访问:http://ip:9090
关闭防火墙
查看日志:
二、在要监控的服务器上安装监听器
在被监控的机器上运行采集数据的脚本软件,普罗米修斯的 exporter,
文件获取:node_exporter-1.3.1.linux-amd64.tar.gz
解压:tar -xvf node_exporter-1.3.1.linux-amd64.tar.gz
启动:
cd node_exporter-1.3.1.linux-amd64
nohup ./node_exporter > node_exporter.log 2>&1 &
端口:9100
netstat -naop | grep 9100.
三、prometheus服务器配置
进入安装目录,修改配置:prometheus.yml
杀掉进程:ps -ef | grep prom
重启:nohup ./prometheus --config.file=prometheus.yml > prom.log 2>&1 &
四、grafana配置大屏
访问grafann,添加数据源
选择 prometheus
添加部署 prometheus 的ip和端口,端口默认9090
五、创建Linux监控看板
文件获取:linux监控看板.json
导入看板:
选择看板数据源:
最终效果:
五、监控windows服务器
deepseek
注意事项
服务器时间校准: yum -y install ntp -y
开机自启动:systemctl enable ntpd
启动:systemctl start ntpd