Monitoring Spring Boot Applications With Prometheus and Grafana

Gunnala SreekanthReddy2 min read
Monitoring Spring Boot Applications With Prometheus and Grafana

Introduction :

Every application that is deployed on production needs some kind of monitoring to see how the application is performing. This will give you some insights on whether the application is performing as expected or if you would need to take some action in order to obtain the desired level of performance. In the modern world, this data is called Application Performance Metrics (APM). 

Today we will be looking at two open-source tools called Grafana and Prometheus. Prometheus gathers and stores metrics data in a time series format while Grafana uses Prometheus as a data source to visualize the data on dashboards. 

Prerequisite :

  1. Java
  2. Spring Boot Application should be enabled actuator and prometheus
  3. Docker: Both Prometheus and Grafana can be run as Docker containers. Therefore, you need to have Docker installed on your system.

https://www.docker.com/products/docker-desktop/

Prometheus Configuration :

  1. Download Prometheus docker image using below cmd

docker pull prom/prometheus

  1. Download prometheus.yaml file from below link

https://www.mediafire.com/file/zabiamfbv8viuyt/prometheus.yaml/file

You will find file like below snapshot

Replace endpoint to your service endpoint like http://192.168.29.155:8080/

  1. Open terminal and hit the below command

docker run -p 9090:9090 -v <replace with your downloaded prometheus.yaml file path>/prometheus.yml prom/prometheus

  1. Open chrome browser and hit url http://your-system-ip-address:9090

Select any metric and click on execute

Grafana Configuration :

  1. Download and run Grafana docker image using below cmd

  docker run -d -p 3000:3000 grafana/grafana-enterprise

  1. Open chrome browser and hit url http://your-system-ip-address:3000

Add Datasource

Move the cursor over the Prometheus Time series database

Enter the endpoint url of the prometheus server in the URL text box below. And click on Save & test

Create new dashboard

Select any metric from list and click Run queries

Ready to build something that matters?

We solve problems that don't have Stack Overflow answers. Let's talk.

Book a Discovery Call