SpringBoot-Admin如何实现微服务监控+健康检查+钉钉告警
发表于:2025-11-13 作者:千家信息网编辑
千家信息网最后更新 2025年11月13日,小编给大家分享一下SpringBoot-Admin如何实现微服务监控+健康检查+钉钉告警,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!基于SpringCloud微服务平台,进行服务实
千家信息网最后更新 2025年11月13日SpringBoot-Admin如何实现微服务监控+健康检查+钉钉告警
小编给大家分享一下SpringBoot-Admin如何实现微服务监控+健康检查+钉钉告警,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
基于SpringCloud微服务平台,进行服务实例监控及健康检查,注册中心为eureka,SpringBoot提供了很好的组件SpringBoot Admin,2.X版本直接可以配置钉钉机器人告警。
效果:可以实现eureka注册的实例上线、下线触发钉钉告警。监控我们的服务实例健康检查。
搭建admin-server
pom依赖
4.0.0 org.springframework.boot spring-boot-starter-parent 2.4.11 com.example admin-server 1.0.0 etc-admin-server Spring Boot Admin监控eureka服务实例和健康检查,钉钉告警 1.8 2.4.3 2020.0.4 org.springframework.boot spring-boot-starter-security org.springframework.boot spring-boot-starter-web de.codecentric spring-boot-admin-starter-server org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.boot spring-boot-starter-test test org.springframework.cloud spring-cloud-dependencies ${spring-cloud.version} pom import de.codecentric spring-boot-admin-dependencies ${spring-boot-admin.version} pom import ${project.name} org.springframework.boot spring-boot-maven-plugin
application.yml配置
spring: application: name: admin-server security: user: name: "admin" password: "pwd" boot: admin: notify: dingtalk: enabled: true webhookUrl: 'https://oapi.dingtalk.com/robot/send?access_token=钉钉机器人access_token' secret: '钉钉机器人secret' message: '服务告警: #{instance.registration.name} #{instance.id} is #{event.statusInfo.status}'server: port: 9002eureka: client: registryFetchIntervalSeconds: 5 service-url: defaultZone: 'http://127.0.0.1:8020/eureka/' instance: hostname: ${spring.cloud.client.ip-address} instance-id: ${spring.cloud.client.ip-address}:${server.port} prefer-ip-address: true ip-address: ${spring.cloud.client.ip-address} leaseRenewalIntervalInSeconds: 10 health-check-url-path: /actuator/health metadata-map: user.name: ${spring.security.user.name} user.password: ${spring.security.user.password}management: endpoints: web: exposure: include: "*" endpoint: health: show-details: ALWAYS启动类
package com.example;import de.codecentric.boot.admin.server.config.EnableAdminServer;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.client.discovery.EnableDiscoveryClient;/** * @author xxx */@EnableAdminServer@EnableDiscoveryClient@SpringBootApplicationpublic class AdminServerApplication { public static void main(String[] args) { SpringApplication.run(AdminServerApplication.class, args); }}config类
package com.example;import de.codecentric.boot.admin.server.config.AdminServerProperties;import org.springframework.context.annotation.Configuration;import org.springframework.security.config.annotation.web.builders.HttpSecurity;import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;import org.springframework.security.web.csrf.CookieCsrfTokenRepository;/** * WebSecurity配置 * @author xxxx */@Configurationpublic class WebSecurityConfigure extends WebSecurityConfigurerAdapter { private final String adminContextPath; public WebSecurityConfigure(AdminServerProperties adminServerProperties) { this.adminContextPath = adminServerProperties.getContextPath(); } @Override protected void configure(HttpSecurity http) throws Exception { // @formatter:off SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); successHandler.setTargetUrlParameter("redirectTo"); successHandler.setDefaultTargetUrl(adminContextPath + "/"); http.authorizeRequests() .antMatchers(adminContextPath + "/assets/**").permitAll() .antMatchers(adminContextPath + "/login").permitAll() .anyRequest().authenticated() .and() .formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and() .logout().logoutUrl(adminContextPath + "/logout").and() .httpBasic().and() .csrf() .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) .ignoringAntMatchers( adminContextPath + "/instances", adminContextPath + "/actuator/**" ); // @formatter:on }}启动后效果
看完了这篇文章,相信你对"SpringBoot-Admin如何实现微服务监控+健康检查+钉钉告警"有了一定的了解,如果想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!
服务
健康
检查
监控
实例
机器
机器人
配置
效果
篇文章
下线
完了
平台
更多
服务平台
版本
知识
组件
行业
资讯
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
linux查找服务器上的文件
软件开发收费方案怎么写
网络技术应用 选修
纪检监察室网络安全整改报告
有一个网络安全学院吗
美国的网络安全部队
苏州提供网络技术有哪些
个人软件开发排名靠前
智能化步道软件开发企业
dbasql数据库优化
无忧在线代理服务器
服务器检测工作流程
江苏信息化软件开发参考价格
润和软件开发岗位
真人棋牌游戏软件开发
武汉网盾科技有限公司服务器租用
俄罗斯网络安全培训
简单的商品数据库
石岐软件开发定制
南通app安卓软件开发
小学护苗网络安全活动总结
宏基笔记本电脑软件开发
我的世界神奇宝贝服务器送神兽送幸运方块
阿里云服务器预装windows
深圳有游戏软件开发公司吗
telpunum网络技术
我的世界手机服务器无人管理
mysql数据库用函数加分
重庆易助网络技术
工商银行软件开发中心是总行