Writing custom health indicators

Spring Boot's Actuator allows you to write a custom health indicator for your application. The Actuator's default /health endpoint provides information about your application status and disk space as follows:

{
   status: "UP",
   diskSpace: {
         status: "UP",
         total: 290391584768,
         free: 209125543936,
         threshold: 10485760
   }
} 

As you can see in the preceding JSON, the /health endpoint returns default health indicator data for common needs such as reporting the health of a disk or database. But you can also provide custom health information—you can register Spring Beans that implement the HealthIndicator interface. You need to provide an implementation of the health() method and return a Health response. The Health response ...

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.