Pro Tips — Server Metric Monitoring with Actuator, Prometheus, and Grafana
Just as important as deployment code is an observability system for tracking whether your server is alive and healthy in real time.
1. Enable Spring Boot Actuator
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
management:
endpoints:
web:
exposure:
include: health, info, metrics, prometheus
endpoint:
health:
show-details: always
Visit http://localhost:8080/actuator/prometheus to see text-format metrics ready for Prometheus scraping.
2. Prometheus + Grafana via Docker
services:
prometheus:
image: prom/prometheus:v2.51.0
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
grafana:
image: grafana/grafana:10.4.0
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
# prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'spring-boot-app'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['host.docker.internal:8080']
3. Essential Grafana Dashboard Panels
Import the JVM Micrometer Dashboard (ID: 4701) to instantly visualize:
| Metric | Purpose |
|---|---|
| JVM Heap Usage | Early OOM detection |
| HTTP Request Rate & Response Time (p95, p99) | API performance anomaly detection |
| DB Connection Pool Utilization | Pool saturation prevention |
| GC Frequency and Pause Time | Memory tuning signals |