弹簧启动执行器未显示内存详细信息

问题描述 投票:0回答:2

我正在尝试在Spring Boot 2.0.2.RELEASE中实现执行器。

pom.xml中的依赖项

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
        <scope>compile</scope>
    </dependency>

application.properties

management.server.port = 8082
management.endpoint.health.enabled=true

自定义健康检查类别

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;
@Component
public class HealthCheck implements HealthIndicator {
@Override
public Health health() {
    int errorCode = check(); // perform some specific health check
    if (errorCode != 0) {
        return Health.down()
          .withDetail("Error Code", errorCode).build();
    }
    return Health.up().build();
}

public int check() {
    // Our logic to check health
    return 0;
}
}

当我打http://localhost:8082/actuator/health在浏览器中,我正在{“状态”:“ UP”}

我希望得到

{
status: "UP",
diskSpace: {
status: "UP",
total: 240721588224,
free: 42078715904,
threshold: 10485760
}
}
spring spring-boot actuator
2个回答

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.