Health Check Endpoint Spring Boot
Here i am going to show how to check database health using spring boot actuator health endpoint spring boot provides actuator endpoints to check application health.
Health check endpoint spring boot. Spring boot actuator https spring io. But in the real world it is often the case that one application relies on other application s availability for performing operations. Also to see the health report from one specific indicator we can call the actuator health name endpoint.
In spring boot microservices based application where microservices talks to each other using restful apis. Dependencies implementation org springframework boot spring boot starter actuator 1 2. Spring boot actuator module helps you monitor and manage your spring boot application by providing production ready features like health check up auditing metrics gathering http tracing etc.
Spring boot actuator database health check. In this case it would be helpful to add a health indicator for the downstream systems just like a database or a file system health check. Management health db enabled true creating custom healthcheck service to check database health.
Along with the overall health of the system. Spring boot aggregates all health indicators it finds in the application context to create the result of the health endpoint we have seen above. So the response of the health check endpoint should contain information about all these subsystems.
All of these features can be accessed over jmx or http endpoints. For example by default the health endpoint is mapped to actuator health. This is elegant as the client only has to hit one url for application status check.
This endpoint will report an aggregated result of all registered healthindicators. The health check provided by a datasource creates a connection to a database and performs a simple query such as select 1 from dual to check that it is working. The client doesnt have to worry about any component failures other than db and ping and you could event set management endpoint health group my health check show details never to just give the status without information for this custom health check.