Spring boot Spring boot-健康端点-我可以有多个URI,一个简单的,其他更详细的吗?
例如,我想在我的spring boot应用程序中有两个与健康相关的端点,一个简单,另一个更详细- 简单API- 详细的API- 但我不知道如何用弹簧启动执行器实现这一点。是的,你可以 开箱即用,Spring Boot注册了许多HealthIndicator来报告特定应用程序方面的健康状况 其中一些指标几乎总是注册的,例如DiskSpaceHealthIndicator或PingHealthIndicator。前者报告磁盘的当前状态,后者作为应用程序的ping端点 另一方面,Spring Boot有条件地注册一些指示器。也就是说,如果某些依赖项在类路径上,或者满足了某些其他条件,Spring Boot可能也会注册一些其他HealthIndicator。例如,如果我们使用的是关系数据库,那么Spring Boot会注册DataSourceHealthIndicator。类似地,如果我们碰巧使用Cassandra作为数据存储,它将注册CassandraHealthIndicator 为了检查Spring引导应用程序的运行状况,我们可以调用/exactor/health端点。此端点将报告所有已注册HealthIndicators的聚合结果 自定义健康指标 除了内置的之外,我们还可以注册定制的HealthIndicators来报告组件或子系统的运行状况。为了实现这一点,我们所要做的就是将HealthIndicator接口的实现注册为SpringbeanSpring boot Spring boot-健康端点-我可以有多个URI,一个简单的,其他更详细的吗?,spring-boot,spring-boot-actuator,Spring Boot,Spring Boot Actuator,例如,我想在我的spring boot应用程序中有两个与健康相关的端点,一个简单,另一个更详细- 简单API- 详细的API- 但我不知道如何用弹簧启动执行器实现这一点。是的,你可以 开箱即用,Spring Boot注册了许多HealthIndicator来报告特定应用程序方面的健康状况 其中一些指标几乎总是注册的,例如DiskSpaceHealthIndicator或PingHealthIndicator。前者报告磁盘的当前状态,后者作为应用程序的ping端点 另一方面,Spring Boo
@Component
public class RandomHealthIndicator implements HealthIndicator {
@Override
public Health health() {}
}
GET http://localhost:8080/actuator/health-detailed
{
"status": "UP",
"components": {
"custom": {
"status": "UP"
},
"diskSpace": {
"status": "UP",
"details": {
"total": 254971625472,
"free": 60132696064,
"threshold": 10485760,
"exists": true
}
},
"ping": {
"status": "UP"
}
}
}
@Component
public class RandomHealthIndicator implements HealthIndicator {
@Override
public Health health() {}
}