SpringBoot-Actuator应用监控以及优雅停机
2017-09-06 14:22
911 查看
Actuator是SpringBoot提供的对应用系统的自省和监控的集成功能,可以对应用系统进行配置查看、相关功能统计等。
添加依赖:
application.yml
一、执行器端点(endpoints) 可用于监控应用及与应用进行交互,Spring Boot包含很
多内置的端点,你也可以添加自己的。例如, health 端点提供了应用的基本健康
信息。 端点暴露的方式取决于你采用的技术类型,大部分应用选择HTTP监控,端
点的ID映射到一个URL。例如, health 端点默认映射到 /management/health 。
下面的端点都是可用的:
HTTP方法 路径 描述 鉴权
GET /autoconfig 查看自动配置的使用情况 true
GET /configprops 查看配置属性,包括默认配置 true
GET /beans 查看bean及其关系列表 true
GET /dump 打印线程栈 true
GET /env 查看所有环境变量 true
GET /env/{name} 查看具体变量值 true
GET /health 查看应用健康指标 false
GET /info 查看应用信息 false
GET /mappings 查看所有url映射 true
GET /metrics 查看应用基本指标 true
GET /metrics/{name} 查看具体指标 true
POST/shutdown 关闭应用 true
GET /trace 查看基本追踪信息 true
如图
二、配置文件配置启用shutdown的HTTP访问
application.properties
配置完成后可通过post请求,停止应用
返回结果:
控制台:
增加安全验证
Maven依赖
application.properties
此时再次发送请求时,则需要进行登录操作后才能执行。
添加依赖:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
application.yml
management: context-path: /management health: mail: enabled: false
一、执行器端点(endpoints) 可用于监控应用及与应用进行交互,Spring Boot包含很
多内置的端点,你也可以添加自己的。例如, health 端点提供了应用的基本健康
信息。 端点暴露的方式取决于你采用的技术类型,大部分应用选择HTTP监控,端
点的ID映射到一个URL。例如, health 端点默认映射到 /management/health 。
下面的端点都是可用的:
HTTP方法 路径 描述 鉴权
GET /autoconfig 查看自动配置的使用情况 true
GET /configprops 查看配置属性,包括默认配置 true
GET /beans 查看bean及其关系列表 true
GET /dump 打印线程栈 true
GET /env 查看所有环境变量 true
GET /env/{name} 查看具体变量值 true
GET /health 查看应用健康指标 false
GET /info 查看应用信息 false
GET /mappings 查看所有url映射 true
GET /metrics 查看应用基本指标 true
GET /metrics/{name} 查看具体指标 true
POST/shutdown 关闭应用 true
GET /trace 查看基本追踪信息 true
如图
二、配置文件配置启用shutdown的HTTP访问
application.properties
#启用shutdown endpoint的HTTP访问 endpoints.shutdown.enabled=true #不需要验证 endpoints.shutdown.sensitive=false
配置完成后可通过post请求,停止应用
返回结果:
{ "message": "Shutting down, bye..." }
控制台:
734896 [Thread-12] INFO com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Close initiated... 734899 [Thread-12] INFO com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Closed.
增加安全验证
Maven依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
application.properties
endpoints.shutdown.sensitive=true security.user.name=admin security.user.password=123456
此时再次发送请求时,则需要进行登录操作后才能执行。
相关文章推荐
- 使用Spring Boot Actuator监控应用
- Spring Boot Actuator监控应用
- Spring Boot 构建应用——使用 Actuator 监控端点
- 使用SpringBoot Actuator监控应用
- Spring Boot参考教程(三)内部应用监控(Actuator)
- springboot(十九):使用Spring Boot Actuator监控应用
- Spring Boot教程(十三)在传统Spring应用中使用spring-boot-actuator模块提供监控端点
- 使用SpringBoot Actuator监控应用示例
- springboot(十九):使用Spring Boot Actuator监控应用
- 在传统Spring应用中使用spring-boot-actuator模块提供监控端点
- 在传统Spring应用中使用spring-boot-actuator模块提供监控端点
- springboot(十九)使用actuator监控应用
- SpringBoot actuator 应用监控。
- springboot 使用Spring Boot Actuator监控应用小结
- 在传统Spring应用中使用spring-boot-actuator模块提供监控端点
- 详解关于springboot-actuator监控的401无权限访问
- 老司机的应用级监控——spring?actuator
- Spring Boot应用之数据加密以及字段过滤
- spring-boot-starter-actuator(健康监控)配置和使用
- Spring Boot教程(十一)Spring Boot Actuator监控端点小结(1)