- 利用Spring Boot的特性进行监控你的应用
- 通过HTTP(最简单方便)
- 通过JMX
- 通过远程shell
- 添加依赖
<!-- actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
- 端点(通过执行器端点可以监控应用及与应用进行交互)
- 端点暴露的方式取决于你采用的监控方式。如果使用HTTP监控,端点的ID映射到一个URL。例如,默认情况下,health端点将被映射到/health。
- 端点会默认有敏感度,根据不同的敏感度是否需要提供用户密码认证
- 如果没启用web安全,则敏感度高的会禁用
- 可以通过配置文件进行配置敏感度
- 默认情况下,除了shutdown外的所有端点都是启用的。
- 配置
#端点的配置
endpoints.sensitive=true
endpoints.shutdown.enabled=true
#保护端点
security.basic.enabled=true
security.user.name=roncoo
security.user.password=roncoo
management.security.roles=SUPERUSER
#自定义路径
security.basic.path=/manage
management.context-path=/manage
- 备注