这篇文章主要介绍了SpringBoot2开启Actuator端点监控的相关资料,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
背景
SpringBoot
本身提供了一套监控端点, 可以查看应用的基本信息、 健康程度、 配置等监控信息, 很容易上手。
Note: 此处所用SpringBoot版本: 2.1.4
开启Actuator
在Maven的pom.xml文件中添加 spring-boot-starter-actuator
依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
直接运行项目, 在后端控制台会看到以下输出:
2019-06- 26 18: 07: 27.896 INFO 7868-- - [restartedMain] o.s.b.a.e.web.EndpointLinksResolver: Exposing 2 endpoint(s) beneath base path '/actuator'
在浏览器访问 http://localhost:9000/actuator
, 结果如下:
即SpringBoot2.0的actuator启动端点监控web端默认加载默认仅info, health两个可见的端点(除了actuator本身之外), 见官方文档说明
暴露其他端点(与SpringBoot 2.0之前的配置不太一样)
management:
endpoints:
web:
exposure:
include: "*"
exclude: env,beans
以上配置暴露了除 env
, beans
之外的所有端点; 修改配置后, 在后端控制台会看到以下输出:
2019-06-26 18: 16: 03.951 INFO 7868-- - [restartedMain] o.s.b.a.e.web.EndpointLinksResolver: Exposing 13 endpoint(s) beneath base path '/actuator'
再次在浏览器访问 http://localhost:9000/actuator
, 结果如下:
Notes:
- 虽然端点
enabled
, 但是还需要exposed
, 才能在Web端访问; health
端点在默认情况下, 仅显示"status": "UP"
; 如需显示详细信息, 配置:management.endpoint.health.show-details=always
- 实际中, 请谨慎选择要开启的端点!
以上配置仅实现了对应用监控信息的获取, 但其实已经有专门用于展现这些 json
数据的管理端, 后续将实践一下SpringBoot Admin这套社区提供的可视化应用监控管理端。 SpringBoot Admin 文档对自己的介绍:
codecentric’ s Spring Boot Admin is a community project to manage and monitor your Spring Boot® applications.The applications register with our Spring Boot Admin Client(via HTTP) or are discovered using Spring Cloud®(e.g.Eureka, Consul).The UI is just a Vue.js application on top of the Spring Boot Actuator endpoints.
到此这篇关于SpringBoot2开启Actuator端点监控的文章就介绍到这了,更多相关SpringBoot2开启Actuator端点监控内容请搜索编程学习网以前的文章希望大家以后多多支持编程学习网!
本文标题为:SpringBoot2开启Actuator端点监控的方法
- Java实现顺序表的操作详解 2023-05-19
- ExecutorService Callable Future多线程返回结果原理解析 2023-06-01
- JSP页面间传值问题实例简析 2023-08-03
- 深入了解Spring的事务传播机制 2023-06-02
- JSP 制作验证码的实例详解 2023-07-30
- Spring Security权限想要细化到按钮实现示例 2023-03-07
- 基于Java Agent的premain方式实现方法耗时监控问题 2023-06-17
- SpringBoot使用thymeleaf实现一个前端表格方法详解 2023-06-06
- Java中的日期时间处理及格式化处理 2023-04-18
- Springboot整合minio实现文件服务的教程详解 2022-12-03