Acturator是spring boot的一个附加功能,可以帮助我们在应用程序中生产环境时监视和管理应用程序,可以通过HTTP的各种请求来监管、审计、收集应用的运行情况,spring boot actuator提供了对单个spring boot的监控,监控信息包含:应用状态、内存、线程、堆栈,可以监控到spring boot应用的整个生命周期。
actuator监控分为两类:原生端点和用户自定义端点。
Actuator配置:
actuator
暴露的监控接口的安全性,需要添加安全控制的依赖
spring
-
boot
-
start
-security
依赖,访问应用监控端点时,都需要输入验证信息。
Security
依赖,可以选择不加,不
进行安全管理。
需要配置的文件,application.properties
management.endpoints.web.exposure.include
=
*
#
展示细节,除了
always
之外还有
when-authorized
、
never
,默认值是
never
management.endpoint.health.show-details
=
always
#
base-path表示服务启动默认请求路劲
Actuator
默认所有的监控点路径都在
/actuator/*
#management.endpoints.web.base-path=/
manage
设置完重启后,再次访问地址就会变成 /manage/*
请求实列:
http://localhost:8080/actuator/beans 表示请求的是/beans
Spring Boot Admin
它是一个针对spring-boot
的
actuator
接口进行
UI
美化封装的监控工具,它可以通过浏览器列表的方式浏览监控spring boot的基本信息比如:spring容器管理所有得bean、health信息、内存信息、jvm信息、垃圾回收信息、各种配置信息(比如数据源、缓存列表和命中率)、thread线程管理、evnironment管理
搭建一个springboot-server服务
pom.xml
在核心启动类上需要加上@EnableAdminServer 用于标注该工程是springboot admin
启动以后页面是
这时候我们需要在client配置 spring-boot-admin-starter-client
client启动以后,我们会发现