Service health check api response 503 when redis is down.
{
"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"
}
}
}
}
But actually service is available when redis is down.
Could service status not be effected by redis status ? and I also need see the redis detail in health check api.
3
Answers
I usually check https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html this to find something like what you are doing
and there I found management.health.redis.enabled (default true)
so my guess would be if you explicitly set this to false it would disappear from your healthcheck
management.health.redis.enabled=false
Add this code to disable the Redis health check in your application.yaml/properties
We solved this issue by overriding
getAggregateStatus
ofSimpleStatusAggregator
so that the redis status is shown in the details, but no influence in the aggregated status.If you have a combination of
ReactiveHealthContributor
andHealthContributor
, you can combine the status