How dilermando-lima/springboot-grafana-prometheus-loki works
Project Type and Purpose
• This is a multi-module Java Spring Boot setup demonstrating how to monitor logs and metrics across separate REST applications.
• It uses three independently deployable services (“api-1”, “api-2”, “runner-1”) plus a Docker-Compose observability stack (Prometheus, Loki, Grafana).
File Structure
• Top-level modules:
• api-1/ (Spring Boot microservice #1)
• api-2/ (Spring Boot microservice #2)
• runner-1/ (Spring Boot client or orchestrator that invokes APIs)
• docker/: contains Prometheus, Loki, and Grafana configuration and compose file.
• Shared Gradle build at the root orchestrates all sub-projects.
Extract Key Architectural Insights from README
• Each Spring Boot app exposes REST endpoints and Spring Actuator metrics.
• Docker Compose runs three observability services:
• Prometheus scrapes metrics from each Spring Boot app.
• Loki collects logs from the Spring Boot apps.
• Grafana visualizes both metrics (from Prometheus) and logs (from Loki).
Main Components
a. Spring Boot Services (api-1, api-2, runner-1)
• Each is a separate JVM process/container.
• Exposes HTTP endpoints and Actuator /metrics and /log endpoints.
b. Docker-Compose Observability Stack
• Prometheus
• Loki
• Grafana
c. External Users / Clients
• A developer or test harness interacting with runner-1 (and possibly directly with api-1/api-2).
Relationships & Data Flows
• External User → HTTP → runner-1
• runner-1 → HTTP → api-1 and api-2
• Each Spring Boot app → HTTP (Actuator scraping) → Prometheus
• Each Spring Boot app → Log shipping (via Docker driver or sidecar) → Loki
• Grafana → Queries → Prometheus & Loki → Displays dashboards
Architectural Patterns & Design Principles
• Microservices pattern: each API as an independent service.
• Observability pipeline pattern: instrumentation (Actuator) → metric/log collector → storage → visualization.
• Separation of concerns: business logic vs. monitoring infrastructure.
Technologies & Frameworks
• Java Spring Boot with Spring Actuator
• Gradle multi-module build
• Docker Compose
• prometheus.yml
• loki config
• grafana
• Grafana dashboards (e.g. template 4701 for JVM/HTTP metrics)