【问题标题】:How to exclude redis check in spring actuator health如何在弹簧执行器健康中排除redis检查
【发布时间】:2020-07-22 22:53:00
【问题描述】:

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 详细信息。

【问题讨论】:

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


    【解决方案1】:

    management.health.redis.enabled=false

    在 application.yaml/properties 中添加此代码以禁用 Redis 健康检查

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • 非常感谢。配置 management.health.redis.enabled 为 false 后,redis 健康检查消失了。但无论如何我可以检查执行器中的 redis 状态吗?
      • 我认为(以前没有做过)你需要为 redis 制作一个自定义的健康指标(提示扩展默认的)并让它总是返回 UP 并在细节中添加它的实际状态否则当 redis 关闭时,您的主要健康检查将关闭
      猜你喜欢
      • 2020-04-11
      • 2020-04-09
      • 1970-01-01
      • 2020-06-17
      • 1970-01-01
      • 1970-01-01
      • 2018-10-29
      • 2022-10-14
      • 1970-01-01
      相关资源
      最近更新 更多