Configure Spring Boot Actuator for health checks, metrics, and production monitoring
OrgStack includes Spring Boot Actuator for comprehensive monitoring and observability. This guide covers setting up health checks, metrics collection, and production monitoring.
# Enable health endpointmanagement.endpoints.web.exposure.include=health,info,metrics,prometheusmanagement.endpoint.health.show-details=when-authorizedmanagement.endpoint.health.probes.enabled=true# Customize management port (optional - use different port than main app)management.server.port=8081
Using a separate management port (8081) allows you to expose health checks to internal networks while keeping the main application (8080) behind a firewall.
Configure your load balancer to use the health endpoint:
1
Choose the health endpoint
Use /actuator/health for general health or /actuator/health/readiness for more accurate traffic routing.
2
Configure check interval
Set appropriate intervals to balance responsiveness and overhead:
Interval: 10-30 seconds
Timeout: 5 seconds
Unhealthy threshold: 2-3 consecutive failures
Healthy threshold: 2 consecutive successes
3
Set up monitoring alerts
Alert when instances fail health checks:
# Example: monitor with curlif ! curl -f http://localhost:8080/actuator/health > /dev/null 2>&1; then echo "Health check failed" | mail -s "OrgStack Alert"[email protected]fi
Never expose /actuator/health with show-details=always in production without authentication. Health details can reveal sensitive information about your infrastructure.
# HELP jvm_memory_used_bytes The amount of used memory# TYPE jvm_memory_used_bytes gaugejvm_memory_used_bytes{area="heap",id="G1 Eden Space",} 1.2345678E7
In Grafana, navigate to Configuration > Data Sources > Add data source > Prometheus
2
Import Spring Boot dashboard
Use the community dashboard for Spring Boot 2.x:
Dashboard ID: 11378 (JVM Micrometer)
Dashboard ID: 12900 (Spring Boot 2.x Statistics)
3
Create custom panels
Add panels for OrgStack-specific metrics:
Organization creation rate
User registration trends
API endpoint latency percentiles
Database query performance
Grafana provides alerting capabilities. Set up alerts for critical metrics like high memory usage, slow response times, or database connection pool exhaustion.
Configure structured logging for better observability:
# Use JSON format for logslogging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} - %msg%nlogging.level.root=INFOlogging.level.com.orgstack=DEBUGlogging.level.org.springframework.web=INFOlogging.level.org.hibernate.SQL=DEBUGlogging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE# Log to filelogging.file.name=/var/log/orgstack/application.loglogging.file.max-size=10MBlogging.file.max-history=30
Use a log aggregation system like ELK Stack (Elasticsearch, Logstash, Kibana) or Splunk to centralize logs from multiple instances.
# Only expose specific endpointsmanagement.endpoints.web.exposure.include=health,info,metrics,prometheusmanagement.endpoints.web.exposure.exclude=env,beans,configprops# Disable specific endpointsmanagement.endpoint.shutdown.enabled=falsemanagement.endpoint.env.enabled=false
The shutdown endpoint allows remote application shutdown via HTTP POST. It is disabled by default, but ensure it stays disabled in production.
Increased traffic: Request rate increases > 50% compared to baseline
Database slow queries: Query execution time > 5 seconds
Memory usage trending up: Steady increase over 6 hours
Start with conservative thresholds and adjust based on your actual usage patterns. Use percentile-based alerts (P95, P99) rather than averages for latency metrics.