Spring Boot Actuator with Prometheus and Grafana for Cloud Monitoring
Introduction
Spring Boot Actuator exposes app metrics. When paired with Prometheus and Grafana, you get full observability.
Architecture
Monitoring Stack
Setup
- Add dependencies:
xml<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>io.micrometer</groupId><artifactId>micrometer-registry-prometheus</artifactId></dependency>
- application.yml
yamlmanagement:endpoints:web:exposure:include: "*"metrics:export:prometheus:enabled: true
- Prometheus config:
yamlscrape_configs:- job_name: 'spring'metrics_path: '/actuator/prometheus'static_configs:- targets: ['host.docker.internal:8080']
Dashboard Example
Grafana Sample
Conclusion
You now have real-time app metrics ready for visualization!