SpringBoot的Actuator监控和Admin-UI可视化

上一篇 << 下一篇 >>>SpringBoot常见面试问题


Actuator 监控管理

Actuator是spring boot的一个附加功能,可帮助你在应用程序生产环境时监视和管理应用程序。可以使用HTTP的各种请求来监管,审计,收集应用的运行情况.特别对于微服务管理十分有意义.
缺点:没有可视化界面。
优点:和jconsole相比功能更多,可查看各个bean单例还是多例,所有的请求地址等等。


    org.springframework.boot
    spring-boot-starter-actuator


###通过下面的配置启用所有的监控端点,默认情况下,这些端点是禁用的;
management:
  endpoints:
    web:
      exposure:
        include: "*"
spring:
  profiles:
    active: prod
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/test
    username: root
    password: root
info: 
  jarye: 
     name: jiang

通过actuator/+端点名就可以获取相应的信息

路径 作用
/actuator/beans 显示应用程序中所有Spring bean的完整列表。
/actuator/configprops 显示所有配置信息。
/actuator/env 陈列所有的环境变量。
/actuator/mappings 显示所有@RequestMapping的url整理列表。
/actuator/health 显示应用程序运行状况信息 up表示成功 down失败
/actuator/info 查看自定义应用信息,必须是以info打头的

Admin-UI

Admin-UI 基于actuator实现能够返回界面展示监控信息,属于服务端代码。


  
    de.codecentric
    spring-boot-admin-starter-server
    2.0.0
  
  
    org.springframework.boot
    spring-boot-starter-webflux
  
  
  
    org.jolokia
    jolokia-core
  
  
    org.springframework.boot
    spring-boot-starter-actuator
  
  
    com.googlecode.json-simple
    json-simple
    1.1
  


spring:
  application:
    name: spring-boot-admin-server

@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class AdminServerApplication {
  public static void main(String[] args) {
    SpringApplication.run(AdminServerApplication.class, args);
  }
}
SpringBoot的Actuator监控和Admin-UI可视化_第1张图片

Admin-UI-Client

Admin-UI的客户端,所有服务的提交者,将本地启动信息上报给服务端展示。


  
    de.codecentric
    spring-boot-admin-starter-client
    2.0.0
  
  
    org.springframework.boot
    spring-boot-starter-actuator
  
  
    org.jolokia
    jolokia-core
  
  
    com.googlecode.json-simple
    json-simple
    1.1
  
  
    org.springframework.boot
    spring-boot-starter-web
  


spring:
  boot:
    admin:
      client:
        url: http://localhost:8080
server:
  port: 8081
  
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS


@SpringBootApplication
public class AppClinet {
  public static void main(String[] args) {
    SpringApplication.run(AppClinet.class, args);
  }
}

推荐阅读:
<< << <<<如何自定义SpringBoot starter
<< << << << << << << << << <<

你可能感兴趣的:(SpringBoot的Actuator监控和Admin-UI可视化)