DEV Community

Vigilmon
Vigilmon

Posted on • Originally published at vigilmon.online

How to Monitor Your Spring Boot Application with Vigilmon

How to Monitor Your Spring Boot Application with Vigilmon

Spring Boot comes with Spring Actuator — a built-in health monitoring framework. But Actuator only works when your server is already running and reachable from inside your network. Vigilmon adds the missing piece: external uptime checks that alert you when the entire app is unreachable.

Spring Actuator + Vigilmon: Better Together

Spring Actuator provides:

  • Internal health checks (/actuator/health)
  • JVM metrics (heap, GC, threads)
  • Database connection pool status
  • Custom health indicators

Vigilmon provides:

  • External HTTP uptime monitoring
  • SSL certificate monitoring
  • Heartbeat monitors for batch jobs
  • Public status pages
  • Multi-region uptime checks

Together they give you complete visibility: Actuator shows what's wrong internally, Vigilmon tells you the app is down from the outside.

Setting Up Spring Actuator Health Endpoint

Add Actuator to your 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 health endpoint in application.properties:

# Expose health endpoint
management.endpoints.web.exposure.include=health
management.endpoint.health.show-details=when-authorized

# For Vigilmon monitoring (public health summary)
management.endpoint.health.show-details=never
management.endpoints.web.base-path=/actuator
Enter fullscreen mode Exit fullscreen mode

This exposes GET /actuator/health which returns:

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

Vigilmon can monitor this endpoint and alert when it returns anything other than {"status": "UP"}.

Adding a Custom Health Endpoint for Vigilmon

For simpler monitoring without exposing Actuator details:

@RestController
@RequestMapping("/health")
public class HealthController {

    private final DataSource dataSource;

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

    @GetMapping
    public ResponseEntity<Map<String, String>> health() {
        Map<String, String> health = new HashMap<>();
        health.put("status", "ok");

        try (Connection conn = dataSource.getConnection()) {
            conn.isValid(2);
            health.put("db", "connected");
        } catch (SQLException e) {
            health.put("status", "degraded");
            health.put("db", "error");
            return ResponseEntity.status(503).body(health);
        }

        return ResponseEntity.ok(health);
    }
}
Enter fullscreen mode Exit fullscreen mode

This endpoint:

  • Returns 200 when healthy
  • Returns 503 when DB is unreachable
  • Tests actual database connectivity (not just that the bean is wired)

Configuring Vigilmon

HTTP Uptime Monitor

  1. Log in to vigilmon.online
  2. Click Add MonitorHTTP(S)
  3. URL: https://yourapp.com/actuator/health or /health
  4. Interval: 60 seconds
  5. Expected HTTP status: 200
  6. Optionally: check that response body contains "status":"UP" or "status":"ok"

SSL Certificate Monitor

  1. Add an SSL Monitor for yourapp.com
  2. Alert threshold: 14 days before expiry

Heartbeat Monitor for Spring Batch Jobs

For Spring Batch jobs or @Scheduled tasks:

@Component
public class VigilmonHeartbeatTask {

    private final RestTemplate restTemplate;

    @Value("${vigilmon.heartbeat.url}")
    private String heartbeatUrl;

    public VigilmonHeartbeatTask(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    @Scheduled(fixedRate = 300_000) // every 5 minutes
    public void pingHeartbeat() {
        try {
            restTemplate.getForEntity(heartbeatUrl, String.class);
        } catch (Exception e) {
            // Log but don't fail — heartbeat failure means Vigilmon will alert
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

In application.properties:

vigilmon.heartbeat.url=https://push.vigilmon.online/YOUR_HEARTBEAT_KEY
Enter fullscreen mode Exit fullscreen mode

In Vigilmon, set the heartbeat monitor to alert if no ping received in 10 minutes.

Custom Health Indicators with Actuator

For specific service dependencies:

@Component
public class ExternalApiHealthIndicator implements HealthIndicator {

    private final RestTemplate restTemplate;
    private final String externalApiUrl;

    @Override
    public Health health() {
        try {
            ResponseEntity<String> response = restTemplate
                .getForEntity(externalApiUrl + "/health", String.class);

            if (response.getStatusCode().is2xxSuccessful()) {
                return Health.up().withDetail("externalApi", "accessible").build();
            }
            return Health.down().withDetail("externalApi", "returned " + response.getStatusCode()).build();
        } catch (Exception e) {
            return Health.down(e).withDetail("externalApi", "unreachable").build();
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Status Page for Your Spring Boot App

For production APIs and services:

  1. Create a Status Page in Vigilmon
  2. Add monitors: main app health, critical APIs
  3. Publish at status.yourapp.com
  4. Link from your API documentation

Alert Configuration

Monitor Alert Condition Channel
/health endpoint Non-200 response Slack + PagerDuty
/actuator/health Status != UP Slack
SSL certificate 14 days to expiry Email
Scheduled job heartbeat Missing 10+ min Slack

Summary

Spring Actuator is excellent for internal monitoring, but it doesn't tell you when the entire application is unreachable from the outside. Vigilmon bridges that gap:

  1. HTTP monitor on /actuator/health or custom /health
  2. SSL monitor for your domain
  3. Heartbeat monitor for @Scheduled tasks and Spring Batch jobs
  4. Status page for users and customers
  5. Response body check to verify Actuator returns "status":"UP"

Vigilmon — external uptime monitoring for Spring Boot and Java applications.

Top comments (0)