springboot如何监控各种指标?
以springboot2.7.17为例:
1:新增如下依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
然后,在你的配置文件(如 application.properties)中添加以下配置:
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
最后,你可以通过 HTTP 请求到 http://localhost:8080/actuator/metrics/tomcat.connections.current 来获取当前活动的 Tomcat 连接数。这需要你的应用已经启动并运行一段时间,以便积累一些活动的连接。
浙公网安备 33010602011771号