Spring streaming response made easy
In this short article, we'll get into stream large size of data through stream as an alternative to the traditional endpoints.
Wed, 10th September 2025
Read MoreBlossoming Intelligence: How to Run Spring AI Locally with Ollama
In this short article, we'll look at how easy it is to create a chat bot backend powered by Spring and Olama using the llama 3 model.
Sat, 11th May 2024
Read MoreMicroservices monitoring is a crucial aspect of managing modern, complex software architectures. Unlike traditional monolithic applications, micro-services break down functionality into smaller, independent services that can be developed, deployed, and scaled independently. Monitoring these services involves tracking their performance, availability, and overall health in real-time. It includes collecting and analyzing various metrics such as response times, error rates, and resource usage. Effective microservices monitoring ensures early detection of issues, enabling quick resolution, minimizing downtime, and optimizing the user experience.
This article will serve as POC, integrating Prometheus and Garafana as monitoriong technologies with a reactive spring application with docker support.
An open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach. — Source
In other words, Prometheus is used to gather the health information and store in a time series database which we can access later on using queries.
Grafana is a multi-platform open source analytics and interactive visualization web application. It provides charts, graphs, and alerts for the web when connected to supported data sources. — Source
In other words, again, Garafana is an analytics and vizualization tool, which will be used to visualize a set of interactive graphs, charts and alerts based on a data source (Prometheus for our case here).
In this project, we will be using Spring Webflux and Spring Docker support, my previous article details the use of theses approaches.
In this app we will be using:
For demo purposes, we’ll create a simple /GET movies endpoint.
In order to expose the health info via prometheus, we need to setup a simple config in our application.yaml file:
To make sure it works, we can check the following url (GET): http://localhost:8080/actuator/prometheus
The results of the request must look like this:
This data will be our input for the Prometheus instance which we’ll going to create next.
Using Spring Docker support, we’re going to create the Prometheus and Grafana containers:
First we must set the needed Prometheus config as /config/prometheus.yaml:
Then we must define our prometheus service in the /compose.yaml
Once we start our Spring Boot app, we must see the Prometheus container up and running at http://localhost:9090/
We can use it to look for the health data we previously fetched filtered by a metric (i.g. jvm_buffer_memory_used_bytes):
In the status > targets we can see that the Spring Boot App is Up as a target:
Similar to Prometheus, Grafana is going to be configured the same way in /config/grafana.env:
And the service should be added to the compose.yaml file:
After running our app, we should be able to access Grafana dashboard using this url: http://localhost:3000/
Then we can log in using admin/admin combination, after skipping the password update interface, we must see the dashboard:
Then, we can set up our datasource:
We need to select Prometheus:
After defining the url to the Prometheus service we can test it.
We can now build our dashboard based on the health info data from the Spring Boot app:
Adding a new visualization:
Adding Prometheus as datasource:
Setting up the search query using the metric explorer:
We use the jvm_memory_used_bytes to have the app used memory:
We use the application label to filter only our app’s data:
Also, we add another filter to only have the heap area:
Then we name our dashboard:
After setting the interval to 5 mins and resizing our graph it should look like this:
We can create also another graph, the same way, for the non-heap memory in the same dashboard:
Then adding names to our charts for better visibility:
A major benefit of using Prometheus and Gafana for monitoring is that they may greatly aid in the early detection of malfunctions. These incredible tools have countless applications beyond what is demonstrated in this post; this proof of concept is only the beginning.
Please, find the full code here.