spring boot actuator 生产就绪功能

Spring Boot包含许多附加功能,可帮助您在将应用程序投入生产时对其进行监视和管理。可以选择使用HTTP端点或JMX管理和监视您的应用程序。审核,运行状况和指标收集可以自动应用于您的应用程序。

只有基于Spring MVC的应用程序才可以通过HTTP终端来监控应用程序的运行指标。

使用Spring Boot actuator配置相关依赖:

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

Web应用默认使用8080端口运行。一旦这个应用启动了,你可以通过http://localhost:8080/actuator来展示所有通过HTTP暴露的endpoints。

默认情况只暴露/actuator/health与/actuator/info这两个endpoint,可能通过修改spring的配置文件application.properties (或application.yml 配置文件名根据项目实际情况而不同)增加 management.endpoints.web.exposure.include=* 一行配置内容暴露其他的endpoint(除了shutdown这个endpoint外)

增加management.endpoint.shutdown.enabled=true 配置可暴露shutdown。

/actuator/health
posted on 2020-04-26 07:16  pcant  阅读(294)  评论(0编辑  收藏  举报