如何排除弹簧执行器健康状况中的Redis检查

时间:2020-04-10 07:49:48

标签: spring spring-boot redis spring-boot-actuator health-check

Redis停止运行时,服务运行状况检查api响应503。

{
    "status": "DOWN",
    "details": {
        "diskSpace": {
            "status": "UP",
            "details": {
                "total": 250790436864,
                "free": 95412813824,
                "threshold": 10485760
            }
        },
        "db": {
            "status": "UP",
            "details": {
                "database": "PostgreSQL",
                "hello": 1
            }
        },
        "refreshScope": {
            "status": "UP"
        },
        "redis": {
            "status": "DOWN",
            "details": {
                "error": "org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379"
            }
        }
    }
}

但是当redis关闭时,实际上可以使用服务。

Redis状态不会影响服务状态吗?而且我还需要在运行状况检查api中查看redis详细信息。

2 个答案:

答案 0 :(得分:0)

我通常会检查https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html来找到类似您正在做的事情

,在那里我找到了management.health.redis.enabled(默认为true) 所以我的猜测是,如果您将其明确设置为false,它将从健康检查中消失

答案 1 :(得分:0)

management.health.redis.enabled=false

添加此代码可在应用程序中禁用Redis运行状况检查。yaml/ properties