Spring Boot Actuator - Disable default scheduling interval
Asked Answered
D

2

1

I am implementing custom Actuator HealthIndicators for my Spring Boot App.

They look something like:

public class MyClass implements HealthIndicator {

    @Override
    public Health health() {
        LOGGER.info("Checking Service Health...");
        try {
            String url = this.getExternalServiceUrl().concat("/heartbeat");
            JSONObject response = this.getResponse(url, null);
            Boolean responseSuccess = response.getBoolean("success");
            Boolean serviceAvailable = ...

            if (responseSuccess && serviceAvailable) {
                return Health.up().withDetail(...).build();
            } else {
                return Health.down().withDetail(...).build();
            }
        } catch (Exception e) {
            return Health.down().withDetail(...).build();
        }
    }
}

Essentially my app is dependent on other external webservices, and when I call my heartbeat page, i want it to ping the heartbeat of those services, and change my apps UP or DOWN status accordingly.

My question here is, it looks like by default Actuator has a 5 minute or so scheduled time in which it will automatically invoke the /actuator/health endpoint. I want to disable this.

I only want the health endpoint called whenever I explicitly call it in the code.

Does anyone know how to disable Actuators default Scheduling?

Im using spring-boot-actuator:2.1.3.RELEASE

Dividend answered 3/12, 2019 at 2:8 Comment(0)
E
4

Spring Boot never automatically calls its own health endpoint. If it is being called every 5 minutes it is something in the environment where you have deployed your application that is doing it.

Enshrine answered 3/12, 2019 at 7:21 Comment(0)
R
0

We were also facing the similar problem then found out that there was internal company library which is calling the health endpoint in particular interval.

Rillings answered 25/9, 2023 at 12:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.