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>
Or build.gradle:
implementation 'org.springframework.boot:spring-boot-starter-actuator'
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
This exposes GET /actuator/health which returns:
{"status": "UP"}
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);
}
}
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
- Log in to vigilmon.online
- Click Add Monitor → HTTP(S)
- URL:
https://yourapp.com/actuator/healthor/health - Interval: 60 seconds
- Expected HTTP status: 200
- Optionally: check that response body contains
"status":"UP"or"status":"ok"
SSL Certificate Monitor
- Add an SSL Monitor for
yourapp.com - 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
}
}
}
In application.properties:
vigilmon.heartbeat.url=https://push.vigilmon.online/YOUR_HEARTBEAT_KEY
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();
}
}
}
Status Page for Your Spring Boot App
For production APIs and services:
- Create a Status Page in Vigilmon
- Add monitors: main app health, critical APIs
- Publish at
status.yourapp.com - 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 | |
| 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:
-
HTTP monitor on
/actuator/healthor custom/health - SSL monitor for your domain
-
Heartbeat monitor for
@Scheduledtasks and Spring Batch jobs - Status page for users and customers
-
Response body check to verify Actuator returns
"status":"UP"
Vigilmon — external uptime monitoring for Spring Boot and Java applications.
Top comments (0)