How to Monitor Your Spring Boot App with Prometheus and Grafana in Kubernetes

Search for a command to run...

glad you liked it!
In this post, we’ll walk through creating a simple Kubernetes cluster on a single AWS EC2 instance using K3s, a lightweight Kubernetes distribution. K3s is easy to install, uses half the memory of standard Kubernetes, and comes in a compact binary of...
This cheat sheet is based on my notes from online courses, Hashicorp documentation, and missing & updated concepts for the Terraform Associate 004 exam after completing the exam. It is optimized for quick revision before the exam. 1. Terraform Core ...

Network wide ad-blocking in your home internet

On My Basement Kubernetes Cluster (With Optional S3 Backups)

In the last blog, I configured an ArgoCD-based GitOps pipeline and deployed my distributed app called vote-app. In this post, I’ll walk through how to set up Prometheus and Grafana to monitor the Kubernetes cluster and track resource usage of the vot...

I've recently configured the Prometheus and Grafana stack on my Kubernetes cluster to monitor system performance, including memory, CPU, and network usage. In this post, I’ll walk you through how I integrated Prometheus into my Spring Boot application to expose application-level metrics. Let's dive in!
Prerequisites
Why Monitor Spring Boot with Prometheus
How It Works
Configure Spring Boot App
Configure Prometheus
Configure the Grafana Dashboard
Summary & Resources
Before you start, make sure you have the following:
A running Kubernetes cluster
Prometheus installed
Grafana installed
ArgoCD (optional) — I used ArgoCD to update Prometheus config, but you can also configure it manually
You might wonder: If Prometheus is already monitoring my Kubernetes cluster, why do I need to monitor the Spring Boot app?
Cluster-level metrics only show infrastructure health. App-level metrics give you insights into how your application is behaving internally.
For example:
Request count and latency (http_server_requests_seconds_count)
Active threads and thread pool usage
JVM memory and GC pauses
HikariCP connection pool metrics
Custom business metrics (e.g., number of logins, votes, etc.)
Spring Boot exposes an endpoint /actuator/prometheus that provides metrics.
Prometheus scrapes this endpoint at regular intervals.
Grafana visualizes these metrics using dashboards.
Update your pom.xml with the following:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
Actuator provides built-in endpoints to display performance information of your application, such as health, metrics, and more.
Micrometer then makes these built-in metrics in a Prometheus understandable format
application.propertiesThis ensures our application is an exposed /actuator/prometheus endpoint, so that later steps, Prometheus can scrape it.
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
⚠️ Exposing all actuator endpoints (
management.endpoints.web.exposure.include=*) is okay for development, but in production, limit it to only what's necessary. See the Spring Actuator docs.
Start your app and visit:
/actuator to see available endpoints

/actuator/prometheus to see Prometheus-readable metrics

That’s it! Your app is now ready to be scraped by Prometheus.
We need to configure Prometheus to scrape metrics from our Spring Boot application. If you installed Prometheus on your own way add the following to your Prometheus config (e.g., prometheus.yml):
- job_name: 'vote-spring-app'
metrics_path: '/actuator/prometheus'
scrape_interval: '10s'
static_configs:
- targets: ['vote.vote-app.svc.cluster.local:8080']
Replace
vote.vote-app.svc.cluster.local:8080with your app's actual address (e.g.,localhost:8080).
In my case, I’ve addedthe above config on the ArgoCD UI by:
Navigate to Application → kuber-prometheus-stack → Details → Parameters.
Edit the Values field with the config above.

After deployment, verify your Spring Boot app appears in Prometheus targets and is in the UP state:

Explore metrics like:
http_server_requests_seconds_count
http_server_requests_seconds_max


While this step is optional, dashboards in Grafana make it easier to view all metrics in one place. And looking into every metric one by one by querying in Prometheus is a repetitive task. So let’s configure the Grafana dashboard.
You can create a Grafana dashboard on your own, but in this blog, I am going to use a pre-configured dashboard from Grafana Dashboards, which is the place you can find lots of great dashboards from the Grafana community. And I chose this Spring Boot 2.1 System Monitor dashboard.
Visit your Grafana website
Use dashboard ID 11378 (Spring Boot 2.1 System Monitor)
Go to Grafana → Import Dashboard
Enter the ID and select Prometheus as the data source

And voilà — your Spring Boot metrics dashboard is ready!



By integrating Spring Boot metrics into your Prometheus and Grafana stack:
You gain insights into your application’s performance and health
It complements your cluster-level observability
Dashboards give you real-time visibility