簡體   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