Skip to content
Advertisement

How can I access the results from spring actuator healthcheck in Java code?

I’ve setup a healthcheck actuator with the endpoint /actuator/health, which produces something like the following for my application when you go to the URL:

JavaScript

Is there a way I can access these results in my Java code using the Spring APIs? I’m monitoring for any that go down and sending out slack notifications when they do, I’m particularly interested in monitoring when the DB goes down. I’ve already got the method that creates the slack notification, I just need the name of the component that has gone down (i.e. db).

Can anyone help with this?

Hopefully my question makes sense, I’m pretty new to this still.

Edit: I’ve @Override Health, if the whole app goes down it goes into this, not sure if there is a way at this stage to get what else is down at the time (db etc) and pass into the slack method?:

JavaScript

Advertisement

Answer

To get more details of the health status you can add following in your application.properties

JavaScript

After that, you will get more information as below.

JavaScript

Solution

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement