Spring Boot Actuator, Prometheus, and Grafana usually work together as a monitoring stack::
🔹 1. Spring Boot Actuator
Purpose: Adds production-ready features to a Spring Boot app.
Uses:
-
Exposes health checks (e.g.,
/actuator/health
) → check if the app is alive. -
Provides metrics endpoints (e.g.,
/actuator/metrics
) → JVM memory, CPU, HTTP request counts, datasource stats, etc. -
Allows application monitoring & management → shutdown, environment info, logging levels (if enabled).
-
Acts as the data source for Prometheus when you add the
micrometer-registry-prometheus
dependency (exposes/actuator/prometheus
).
🔹 2. Prometheus
Purpose: A time-series database & monitoring system.
Uses:
-
Scrapes metrics from targets (like
/actuator/prometheus
from your Spring Boot app). -
Stores metrics as time series data.
-
Supports PromQL (Prometheus Query Language) to query and aggregate data.
-
Provides alerting (integrates with Alertmanager to send alerts via email, Slack, etc.).
-
Efficient for real-time monitoring of microservices, infrastructure, and applications.
Example: Prometheus pulls http_server_requests_seconds_count
from Actuator and stores it with timestamps → lets you know how many requests hit your app.
🔹 3. Grafana
Purpose: A visualization and analytics tool.
Uses:
-
Connects to Prometheus (or other data sources) and builds dashboards.
-
Lets you plot charts, graphs, heatmaps for metrics.
-
Helps in root-cause analysis by correlating metrics (e.g., “CPU high → request latency increases”).
-
Can set up alerts with custom thresholds and send notifications (email, Teams, Slack, etc.).
-
Used to present monitoring data in a clear, user-friendly way for devs, ops, and managers.
🔗 How They Work Together
-
Spring Boot Actuator → exposes metrics in a format Prometheus can read.
-
Prometheus → scrapes those metrics at intervals (e.g., every 15s), stores them, and lets you query them.
-
Grafana → queries Prometheus and builds interactive dashboards to visualize application health & performance.
✅ In short:
-
Actuator = generates app metrics.
-
Prometheus = collects, stores, and queries metrics.
-
Grafana = visualizes and alerts on metrics.