@ApplicationScoped
class MyChecks {
@Produces
@Liveness
HealthCheck check1() {
return () -> HealthCheckResponse.named("heap-memory").state(getMemUsage() < 0.9).build();
@Produces
@Readiness
HealthCheck check2() {
return () -> HealthCheckResponse.named("cpu-usage").state(getCpuUsage() < 0.9).build();
This document defines the protocol to be used by components that need to ensure a compatible wireformat, agreed upon semantics and possible forms of interactions between system components that need to determine the “liveliness” or "readiness" of computing nodes in a bigger system.
Note that the force of these words is modified by the requirement level of the document in which they are used.
MUST This word, or the terms "REQUIRED" or "SHALL", mean that the
definition is an absolute requirement of the specification.
MUST NOT This phrase, or the phrase "SHALL NOT", mean that the
definition is an absolute prohibition of the specification.
SHOULD This word, or the adjective "RECOMMENDED", mean that there
may exist valid reasons in particular circumstances to ignore a
particular item, but the full implications must be understood and
carefully weighed before choosing a different course.
SHOULD NOT This phrase, or the phrase "NOT RECOMMENDED" mean that
there may exist valid reasons in particular circumstances when the
particular behavior is acceptable or even useful, but the full
implications should be understood and the case carefully weighed
before implementing any behavior described with this label.
MAY – This word, or the adjective “OPTIONAL,” mean that an item is truly discretionary.
MUST be compatibility with well known cloud platforms (i.e. http://kubernetes.io/docs/user-guide/liveness/)
MUST be appropriate for machine-to-machine communication
SHOULD give enough information for a human administrator
Consumer
The probing end, usually a machine, that needs to verify the liveness or readiness of a Producer
Health Check Procedure
The code executed to determine the liveliness of a Producer
Producer status
The overall status, determined by considering all health check procedure results
Health check procedure result
The result of single check
Producers MAY support a variety of protocols but the information items in the response payload MUST remain the same.
Producers SHOULD define a well known default context to perform checks
Each response SHOULD integrate with the outermost protocol whenever it makes sense (i.e. using HTTP status codes to
signal the overall status)
Inner protocol information items MUST NOT be replaced by outer protocol information items, rather kept redundantly.
The inner protocol response MUST be self-contained, that is carrying all information needed to reason about the producer status
The primary information MUST be boolean, it needs to be consumed by other machines. Anything between available/unavailable doesn’t make sense or would increase the complexity on the side of the consumer processing that information.
The response information MAY contain an additional information holder
Consumers MAY process the additional information holder or simply decide to ignore it
The response information MUST contain the boolean status
of each check
The response information MUST contain the name of each check
Producers MAY support an additional information holder with key/value pairs to provide further context (i.e. disk.free.space=120mb).
The JSON response payload MUST be compatible with the one described in Appendix B
The JSON response MUST contain the name
entry specifying the name of the check, to support protocols that support external identifier (i.e. URI)
The JSON response MUST contain the status
entry specifying the state as String: “UP” or “DOWN”
The JSON MAY support an additional information holder to carry key value pairs that provide additional context
A producer with no health check procedures expected or installed MUST return positive overall status (i.e. HTTP 200)
A producer with health check procedures expected but not yet installed MUST return negative overall status (i.e. HTTP 503)
The synthesized response MUST contain a name
entry with a value set to the runtime class name of the failing check.
The synthesized response MAY contain additional information about the failure (i.e. exception message or stack trace)
An implementation is allowed to supply a reasonable default (out-of-the-box) procedures as
defined in the Health Check Procedures section. To disable
all default vendor procedures users can specify a
MicroProfile Config configuration property
mp.health.disable-default-procedures
to true
. This allows the application to process and
display only the user-defined health check procedures.
Check with no procedures expected or installed. See With no procedures expected or installed into the runtime
/health/live
/health/ready
/health
Check failed
/health/live
/health/ready
/health
Check with procedures expected but not yet installed. See With procedures expected but not yet installed into the runtime
/health/live
/health/ready
/health
Undetermined
Request processing failed (i.e. error in procedure)
Implementors of the API are expected to supply implementations of HealthCheckResponse
and HealthCheckResponseBuilder
by providing a HealthCheckResponseProvider
to their implementation. The HealthCheckResponseProvider
is discovered using the default JDK service loader.
A HealthCheckResponseProvider
is used internally to create a HealthCheckResponseBuilder
which is used to construct a HealthCheckResponse
. This pattern allows implementors to extend a HealthCheckResponse
and adapt it to their implementation needs. Common implementation details that fall into this category are invocation and security contexts or anything else required to map a HealthCheckResponse
to the outermost invocation protocol (i.e. HTTP/JSON).
The following changes occurred in the 2.1 release, compared to 2.0
A full list of changes may be found on the MicroProfile Health Check 2.1
Add new method to create responses
Add config property to disable implementation Health Check procedures
Improve javadoc
In response JSON format replaced outcome
and state
by status
. This change breaks backward compatibility with version 1.0
Introduction of /health/live
endpoint that must call all the liveness procedures
Introduction of /health/ready
endpoint that must call all the readiness procedures
For backward compatibility, /health
endpoint should now call all procedures having @Health
, @Liveness
or @Readiness
qualifiers
Correction and enhancement of response JSON format.