Reputation: 31122
I couldn't find it documented anywhere... when to use which?
My wild guess is that Status.OUT_OF_SERVICE
means that the service is deliberately shut down, while Status.DOWN
means that the service is unhealthy (not necessarily unavailable, it just should be looked at).
Upvotes: 3
Views: 7434
Reputation: 3150
Your guess is a bit incorrect. Both DOWN
and OUT_OF_SERVICE
are statuses of the various components in spring actuator realm. In simple terms:
DOWN
means that the component is unavailbleOUT_OF_SERVICE
means that the component is not yet readyUse whatever status makes sense in your case, but in general both of these statuses will return 503 to the http callee by default. So the difference is mainly for description purposes.
For debuggers out there - out of my own experiance, I will say that most of the time in spring boot itself you will expriance the OUT_OF_SERVICE
status becuase of the readinessState probe. In order to check it and verify the source of the problem you can set this property:
management.endpoint.health.show-details=always
Or you can request the readinessState prob directly via /actuator/health/readiness
, but I'd prefer the first approach since it provides a lot of debugging info so you will identify the cause sooner.
P.S: If the readiness probe is in the OUT_OF_SERVICE
state, then you need to check that all of your synchronous:
EventListener
-sApplicationRunner
-sCommandLineRunner
-s etcare finished successfuly. If any of them block the current thread, then spring will consider that the application is not yet ready, and will constantly return OUT_OF_SERVICE
for readinessProbe until thread is released.
Upvotes: 0
Reputation: 940
If believe the Javadoc for org.springframework.boot.actuate.health.Status
answers this:
(Although I also think the documentation in this area could be improved with some examples.)
/**
* {@link Status} indicating that the component or subsystem has suffered an
* unexpected failure.
*/
public static final Status DOWN = new Status("DOWN");
/**
* {@link Status} indicating that the component or subsystem has been taken out of
* service and should not be used.
*/
public static final Status OUT_OF_SERVICE = new Status("OUT_OF_SERVICE");
As you correctly guessed, DOWN
is unexpected downtime whereas OUT_OF_SERVICE
means a service was deliberately shut down.
Upvotes: 0
Reputation: 1747
The docs http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#_writing_custom_healthindicators give an example of a custom order severity. The default OrderedHealthAggregator uses an order like this
Status.DOWN, Status.OUT_OF_SERVICE, Status.UP, Status.UNKNOWN
So spring boot considers DOWN more "severe" than OUT_OF_SERVICE. By default both map to HTTP 503 Service Unavailable for the /health endpoint. So really out of the box if you use either you will see the same behavior. None of the spring provided health indicators use OUT_OF_SERVICE. They just use DOWN.
Upvotes: 2