SpringBoot四大核心之actuator——程序监控器

63 阅读1分钟

四大核心

1、Actuator:springboot程序监控器 2、自动装配:简单配置甚至零配置即可运行项目 actuator

这是springboot程序的监控系统,可以实现健康检查,info信息等。在使用之前需要引入spring-boot-starter-actuator,并做简单的配置即可。

引入依赖

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

权限判断 management.security.enabled=false

spring boot暴露所有的http路径

management.endpoints.web.exposure.include=* management.endpoints.web.base-path=/ 配置了这个就是info,没有配置这个就是:/actuator/info

编写配置

# actuator 监控配置
management:
  #actuator端口 如果不配置做默认使用上面8080端口
  server:
    port: 8080
  endpoints:
    web:
      exposure:
        #默认值访问health,info端点  用*可以包含全部端点
        include: "*"
      #修改访问路径 2.0之前默认是/; 2.0默认是/actuator可以通过这个属性值修改
      base-path: /actuator
  endpoint:
    shutdown:
      enabled: true #打开shutdown端点
    health:
      show-details: always #获得健康检查中所有指标的详细信息

启动程序