SpringCloud Admin健康检查

1. 什么是 Spring Boot Admin?

Spring Boot Admin 是 codecentric 公司开发的一款开源社区项目,目标是让用户更方便的管理以及监控 Spring Boot ® 应用。 应用可以通过我们的Spring Boot Admin客户端(通过HTTP的方式)或者使用Spring Cloud (比如Eureka,consul的方式)注册。 而前端UI则是使用Vue.js,基于Spring Boot Actuator默认接口开发的。官网地址是https://github.com/codecentric/spring-boot-admin。

 
主要功能如下:

  1. 显示健康状况
  2. 显示详细指标(如:jvm、内存,micrometer、数据源、缓存等)
  3. 监控并下载日志文件
  4. 显示 jvm 中的系统、以及环境变量
  5. 显示 Spring Boot 配置属性
  6. 简单的日志级别管理
  7. 支持与 JMX bean 交互
  8. 显示线程堆栈
  9. 下载堆信息
  10. 显示 http 跟踪
  11. 显示 http 端点
  12. 显示计划任务
  13. 显示/ 删除活动会话
  14. 显示 Flyway / Liquibase 迁移
  15. 状态变更通知

2、实战

Spring Boot Admin是通过client和serve的方式工作的。新建了AdminServe的模块作为Spring boot admin的serve。引入依赖:

 <!-- Admin 服务 -->
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-server</artifactId>
        <version>2.6.6</version>
    </dependency>
    <!-- Admin 界面 -->
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-server-ui</artifactId>
        <version>2.6.6</version>
    </dependency>

启动类添加@EnableAdminServer。
 
application.properties配置:

server.port=7500

spring.application.name=adminServe

 
 

每个要监控的服务就是Spring boot admin的client,添加依赖

       <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-client</artifactId>
        <version>2.2.1</version>
    </dependency>

SpringCloud版本是Hoxton.SR9,spring-boot-admin-starter-client版本要选择2.2.1。SpringCloud版本是2021.0.6,spring-boot-admin-starter-client版本要选择2.6.6。在application.properties添加:

management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
spring.boot.admin.client.url=http://localhost:7500

 
 

启动EurekaServe,两个Producer,一个Consumer,访问http://localhost:7500/,看到:

 
 

点进consumer中看到:

 
可以看到左边的监控指标。

posted @   shigp1  阅读(225)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
点击右上角即可分享
微信分享提示