'How to get access to the Spring-boot actuator JSON payload

I m working on a customized health check for an API. Where I m using :

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <version>2.5.5</version>
        </dependency>

and implementing the HealthIndicator interface. I m wondering if there is a way to get access to the payload returned by /actuator/health ? so I can desterilize it, and base on the values on the object (payload), I will build the implementation for the heath() method from HealthIndicator Interface.

I have tried to use: - HealthEndpoint but it needs an implementation for HealtContributorRegistary , not sure how to do that. - SystemHealth (im getting the error : class Cannot be accessed from outside package).

any help is very welcomed. Thank you.



Solution 1:[1]

I was able to get access to all my API components status by

@Autowired HealthContributor[] healthContributors;

in a service. I have followed this answer : Direct access to Spring Boot Actuator Health beans/data?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BSL