spring boot Actuator 服务监控与管理
spring boot Actuator
spring boot 的服务监控与管理
actuator 是 spring boot 项目中非常强大一个功能,有助于对应用程序进行监视和管理,通过 restful api 请求来监管、审计、收集应用的运行情况,针对微服务而言它是必不可少的一个环节…
actuator 的监控接口:
Actuator 监控分成两类:原生端点和用户自定义端点;自定义端点主要是指扩展性,用户可以根据自己的实际应用,定义一些比较关心的指标,在运行期进行监控。
原生端点是在应用程序里提供众多 Web 接口,通过它们了解应用程序运行时的内部状况。原生端点又可以分成三类:
应用配置类:可以查看应用在运行期的静态信息:例如自动配置信息、加载的 springbean 信息、yml 文件配置信息、环境信息、请求映射信息;
度量指标类:主要是运行期的动态信息,例如堆栈、请求连、一些健康指标、metrics 信息等;
操作控制类:主要是指 shutdown,用户可以发送一个请求将应用的监控功能关闭。
接口地址:
简单入门:
添加依赖
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> </dependencies>
添加配置
info.app.name=spring-boot-actuatorinfo.app.version= 1.0.0info.app.test=test#可以打开所有的监控点 默认只打开 info 和 healthmanagement.endpoints.web.exposure.include=*#关闭监控点#management.endpoints.web.exposure.exclude=beans,tracemanagement.endpoint.health.show-details=always#监控请求地址 默认 /actuator/*#management.endpoints.web.base-path=/monitor#打开关闭应用端点management.endpoint.shutdown.enabled=true
启动访问 http://127.0.0.1:8080/actuator 查看监控信息
端点详细参考:
https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。