Writing a custom health check
Another critical feature needed when we take our application to production is monitoring it. In the olden days, people would set up a CRON job to ping a server and see if it was up. More intricate systems would track disk usage, memory usage, and ideally page someone when the database was at 95%, so it could be saved before falling over.
Spring Boot provides a new era in health check monitoring. To kick things off, launch the application and visit /application/health
:
{ status: "UP", diskSpace: { status: "UP", total: 498937626624, free: 96519303168, threshold: 10485760 }, mongo: { status: "UP", version: "3.4.6" }}
Out of the box, this provides us with an endpoint we can ping and additionally, gives us some information regarding disk space. It also includes an automatically included MongoDB health check.
But what if we needed to write our own health check? Perhaps, there is a system we are dependent upon. Knowing...