Monitoring Your Spring Boot Application with Vigilmon: Actuator Health + External Uptime

java dev.to

Monitoring Your Spring Boot Application with Vigilmon: Actuator Health + External Uptime

Spring Boot applications power enterprise backends worldwide. Spring Boot Actuator provides internal health endpoints — but you also need external monitoring to verify users can actually reach your service. This guide combines Spring Actuator with Vigilmon for comprehensive coverage.

Spring Boot Actuator Health Endpoint

Spring Boot Actuator ships a /actuator/health endpoint out of the box.

Setup

Add to pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Enter fullscreen mode Exit fullscreen mode

Or build.gradle:

implementation 'org.springframework.boot:spring-boot-starter-actuator'
Enter fullscreen mode Exit fullscreen mode

Configure in application.yml:

management:
  endpoints:
    web:
      exposure:
        include: health
  endpoint:
    health:
      show-details: when-authorized
  health:
    defaults:
      enabled: true
Enter fullscreen mode Exit fullscreen mode

This exposes GET /actuator/health which returns:

{"status":"UP"}
Enter fullscreen mode Exit fullscreen mode

Custom Health Indicator

Add custom health checks:

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

@Component
public class DatabaseHealthIndicator implements HealthIndicator {

    private final DataSource dataSource;

    public DatabaseHealthIndicator(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    public Health health() {
        try (Connection conn = dataSource.getConnection()) {
            conn.prepareStatement("SELECT 1").execute();
            return Health.up().withDetail("database", "reachable").build();
        } catch (Exception e) {
            return Health.down().withDetail("error", e.getMessage()).build();
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Expose a Simple Health Endpoint

If you prefer a simple endpoint without Actuator:

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

@RestController
public class HealthController {

    @GetMapping("/health")
    public ResponseEntity<Map<String, String>> health() {
        return ResponseEntity.ok(Map.of("status", "ok"));
    }
}
Enter fullscreen mode Exit fullscreen mode

Setting Up Vigilmon for Spring Boot

  1. Sign up at vigilmon.online
  2. Click Add Monitor
  3. URL: https://your-spring-app.com/actuator/health or /health
  4. Check interval: 1 or 5 minutes
  5. Alert channels: email and/or webhook
  6. Expected status: 200
  7. Save

Vigilmon checks from multiple geographic regions. Only alerts when 2+ regions agree your endpoint is down — no false alerts from regional network blips.

Security Consideration: Protecting Actuator Endpoints

Be careful about publicly exposing /actuator/health with full details. Use Spring Security to restrict sensitive details:

management:
  endpoint:
    health:
      show-details: when-authorized  # Only full details when authenticated
      show-components: always         # Component statuses always visible
Enter fullscreen mode Exit fullscreen mode

For Vigilmon, the public /health endpoint returning {"status": "UP"} is sufficient. Keep sensitive Actuator endpoints (env, beans, etc.) behind authentication.

What to Monitor

Monitor URL Notes
Main health /actuator/health Core app status
Specific service /health Your custom endpoint
API entry point /api/v1/ping Specific API working
Auth endpoint /api/auth/verify Auth service up

Kubernetes Integration

spec:
  containers:
  - name: spring-app
    livenessProbe:
      httpGet:
        path: /actuator/health/liveness
        port: 8080
      initialDelaySeconds: 60
      periodSeconds: 10
    readinessProbe:
      httpGet:
        path: /actuator/health/readiness
        port: 8080
      initialDelaySeconds: 30
      periodSeconds: 5
Enter fullscreen mode Exit fullscreen mode

Then add https://your-public-domain.com/actuator/health to Vigilmon for external monitoring.

Conclusion

Spring Boot Actuator gives you internal health visibility. Vigilmon gives you external uptime monitoring — verifying that users around the world can actually reach your service. Together they provide complete coverage.

Start free at vigilmon.online — 5 monitors, no credit card, live in 2 minutes.

Source: dev.to

arrow_back Back to Tutorials