摘要
SpringBoot集成Prometheus实现Alert Manager告警上报
一、准备工作
一个可用的vm 系统:CentOS7
两个springboot项目:创建Srpingboot项目 (一个作为被监控的服务,一个作为接收告警上报服务)
下载Prometheus:Prometheus
下载AlertManager:AlertManager
Prometheus官网 如果需要其他版本或其他组件,请自行下载
二、安装启动Prometheus
1、解压:[root@localhost opt]# tar -zxfv prometheus-2.47.0.linux-amd64.tar.gz
2、启动
[root@localhost opt]# cd prometheus-2.47.0.linux-amd64/
在目录下启动
[root@localhost opt]# ./prometheus --config.file=prometheus.yml
或者用
nohup ./prometheus --config.file=prometheus.yml > prometheus.out 2>&1 &
3、打开Prometheus UI界面:http://IP地址:9090 我当前VM的地址 http://192.168.160.151:9090/
启动Prometheus成功
三、安装AlertManager
1、解压:
[root@localhost opt]# tar -zxfv alertmanager-0.26.0.linux-amd64.tar.gz
2、启动
[root@localhost opt]# cd alertmanager-0.26.0.linux-amd64/
在目录下启动
[root@localhost opt]# ./alertmanager --config.file=alertmanager.yml
或者用
nohup ./alertmanager --config.file=alertmanager.yml > alert.out 2>&1 &
打开AlertManager UI界面:http://IP地址:9093 我当前VM的地址:http://192.168.160.151:9093/
四、注意事项:
1、Linux的防护墙问题:会导致两个组件的界面无法访问,需要开通端口。
判断依据:关闭防火墙是否可以访问
systemctl stop firewalld.service