我使用SpringBoot驱动程序来返回应用程序的健康状况。Spring Boot Actuator - 自定义健康端点
public class HealthMonitor implements HealthIndicator {
@Override
public Health health() {
int errorCode = check();
if (errorCode != 0) {
return Health.down().withDetail("Error Code", errorCode).build();
}
return Health.up().build();
}
public int check() {
return 0;
}
}
我看到下面的响应
{
"status": "UP",
"diskSpace": {
"status": "UP",
"free": 55020113920,
"threshold": 10485760
},
"db": {
"status": "UP",
"database": "Oracle",
"hello": "Hello"
}
}
我想回到类似于下面
{status: "Healthy"}
有没有办法做到这一点的回应?
而不是返回'Health'实例返回检查后,您的自定义响应'errorCode' – 11thdimension
我不该在这种情况下实施HealthIndicator的?有没有办法像我提到的使用Health实例一样返回自定义消息? –
我以为'健康'是一些正常的班级。我自己尝试过,现在唯一的办法就是保护这个服务免受外部使用,并创建一个像'/ customHealth'这样的定制服务,并在服务器上使用这个'/ health'服务来获取定制中的状态信息服务。 – 11thdimension