【发布时间】:2019-09-30 22:04:20
【问题描述】:
有现有的执行器健康端点,例如:
/actuator/health
我将如何扩展这个现有的端点来表示:
/actuator/health/myendpoint
为了执行一些健康检查?
当前代码:
package com.example.actuatordemo.health;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.stereotype.Component;
@Component
public class CustomHealthIndicator extends AbstractHealthIndicator {
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
// Use the builder to build the health status details that should be reported.
// If you throw an exception, the status will be DOWN with the exception message.
builder.up()
.withDetail("app", "Testing endpoint extension!")
.withDetail("error", "Oops.");
}
}
【问题讨论】:
标签: endpoint spring-boot-actuator health-monitoring