- 利用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
- 備註