繁体   English   中英

不显示Spring Boot Actuator / health端点的磁盘空间和数据库

[英]Do not show diskspace and db for Spring Boot Actuator /health endpoint

我正在运行Spring Boot v1.5.2.RELEASE。

当我curl localhost:8080/health我得到:

{
    "status": "UP",
    "test": {
        "status": "UNKNOWN",
        "hello": "test123"
    },
    "diskSpace": {
        "status": "UP",
        "total": 999234207744,
        "free": 806942392320,
        "threshold": 10485760
    },
    "db": {
        "status": "UP",
        "database": "MySQL",
        "hello": 1
    }
}

这是我下面的TestHealthIndicator.java代码:

import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health.Builder;
import org.springframework.stereotype.Component;

@Component
public class TestHealthIndicator extends AbstractHealthIndicator {

    @Override
    protected void doHealthCheck(Builder builder) throws Exception {
        builder.withDetail("hello", "test123");
    }
}

我的pom.xml也有这个:

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

问题 :如何使/health返回类似以下的内容而没有数据库和磁盘空间信息?

{
    "status": "UP",
    "test": {
        "status": "UNKNOWN",
        "hello": "test123"
    }
}

根据文档,您可以使用以下属性禁用所有自定义HealthIndicator Bean:

management.health.defaults.enabled=false

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM