This repository demonstrates a production-grade observability pipeline for a Java 21 Spring Boot application. It covers the full lifecycle of a metric: from code instrumentation with Micrometer, to collection via Prometheus, and professional visualization in Grafana.
The application is containerized and deployed on a Kubernetes (Minikube) cluster. The monitoring infrastructure is managed using Helm via the kube-prometheus-stack.
Validation of the monitoring stack and application pods running in the java-monitoring-demo namespace:
To bridge the gap between the internal Kubernetes network and the local host, the following service exposures were implemented:
-
Application Access: Exposed via Minikube tunnel to track endpoint traffic.

-
Grafana Access: Port-forwarded to
localhost:3000for real-time dashboarding.
The Java application exposes custom endpoints and standard JVM metrics via the Spring Boot Actuator.
- Success Path: Tracking standard traffic on the
/api/helloendpoint.
- Error Simulation: Monitoring for 500-series errors to trigger future alerts.

Using the JVM (Micrometer) Dashboard (ID: 4701), we achieve deep-dive visibility into the Java Virtual Machine performance.
A high-level view of application health, including CPU utilization and memory trends.

Detailed tracking of heap usage and garbage collection pauses to prevent "Out Of Memory" (OOM) errors.

Monitoring class-loading counts and buffer pool allocations.

- Service Discovery: Utilized Prometheus
ServiceMonitorlabels to automatically discover the Java service. - Metric Customization: Integrated Micrometer
Counterto track business-specific metrics (api_requests_total). - Resource Management: Configured Kubernetes resource limits to observe behavior under load within Grafana.
- Start Minikube:
minikube start - Apply Manifests:
kubectl apply -f k8s/ - Install Monitoring:
helm install monitoring prometheus-community/kube-prometheus-stack -n java-monitoring-demo - View Dashboards: Use
kubectl port-forwardas documented in the assets above.
