Skip to content

End-to-end Observability for a Spring Boot application using Kubernetes, Prometheus, and Grafana

Notifications You must be signed in to change notification settings

Inscode/java-k8s-observability

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Java Cloud-Native Observability Stack

End-to-End Monitoring with Kubernetes, Prometheus, and Grafana

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.


🏗️ Architecture & Infrastructure

The application is containerized and deployed on a Kubernetes (Minikube) cluster. The monitoring infrastructure is managed using Helm via the kube-prometheus-stack.

Cluster Health

Validation of the monitoring stack and application pods running in the java-monitoring-demo namespace:

Cluster Pods Status


🛠️ Accessing the Stack

To bridge the gap between the internal Kubernetes network and the local host, the following service exposures were implemented:

  1. Application Access: Exposed via Minikube tunnel to track endpoint traffic. Application Service

  2. Grafana Access: Port-forwarded to localhost:3000 for real-time dashboarding. Grafana Port Forward


📈 Application Insights

The Java application exposes custom endpoints and standard JVM metrics via the Spring Boot Actuator.

API Endpoints

  • Success Path: Tracking standard traffic on the /api/hello endpoint. Hello Endpoint
  • Error Simulation: Monitoring for 500-series errors to trigger future alerts. Error Endpoint

📊 Observability Dashboards

Using the JVM (Micrometer) Dashboard (ID: 4701), we achieve deep-dive visibility into the Java Virtual Machine performance.

1. Performance Overview

A high-level view of application health, including CPU utilization and memory trends. JVM Overview CPU and Memory

2. Memory Management & Garbage Collection (GC)

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

3. Resource Internals

Monitoring class-loading counts and buffer pool allocations. Classloading and Buffer


💡 Key Technical Takeaways

  • Service Discovery: Utilized Prometheus ServiceMonitor labels to automatically discover the Java service.
  • Metric Customization: Integrated Micrometer Counter to track business-specific metrics (api_requests_total).
  • Resource Management: Configured Kubernetes resource limits to observe behavior under load within Grafana.

🚀 How to Run Locally

  1. Start Minikube: minikube start
  2. Apply Manifests: kubectl apply -f k8s/
  3. Install Monitoring: helm install monitoring prometheus-community/kube-prometheus-stack -n java-monitoring-demo
  4. View Dashboards: Use kubectl port-forward as documented in the assets above.

About

End-to-end Observability for a Spring Boot application using Kubernetes, Prometheus, and Grafana

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published