Monitor Spring Boot API Performance — Introduction

Dilshan Pathirana
JavaToDev
Published in
4 min readJan 7, 2024

As more people join the online world, keeping tabs on how web services perform has become incredibly crucial. Plus, with the rise of microservices architecture, teams are handling way more services than ever. That’s why having a setup that’s user-friendly, easy to grasp, and great for analysis is an absolute must for software companies to monitor their services.

Photo by Tobias Tullius on Unsplash

Spring Boot Actuator

Before the introduction of Spring Boot people had to implement their framework to gather monitoring data. Thankfully Spring boot actuator exposes inbuilt metrics with the help of a micrometer. The actuator mainly exposes operational information about the running application such as health, metrics and info

Micrometer

Micrometer comprises a collection of Java libraries designed for capturing metrics and disseminating them to various tools (Micrometer serves as an instrumentation facade). We can use the spring boot actuator to publish those metrics generated by the micrometer as a REST endpoint.

Photo by Gavin Allanwood on Unsplash

The Spring boot actuator gives us instantaneous metrics when someone accesses the above-mentioned endpoint. As an example if we want the count of API calls that hit a specific API. As an example it will give the count of the API calls up to now from the time the service has started. It will not provide any idea about how the matrices vary with time. Even though some instantaneous matrices are useful to derive conclusions. Most of the time we can get more useful and important insights by analysing these metrics as a time series. And there is no use analysing matrices if our system does not alert the required parties when somethings go wrong in our monitored artifact.

We can achieve both above requirements by connecting our sprint boot actuator to a monitoring system. A monitoring system is a technical infrastructure designed to oversee, track, and collect data from various sources such as hardware, software, applications, networks, or operating systems. Different monitoring systems accept data in different formats. Luckily micrometers can produce matrices for different monitoring systems such as

  • Netflix Atlas
  • CloudWatch
  • Datadog
  • Ganglia
  • Graphite
  • InfluxDB
  • JMX
  • New Relic
  • Prometheus
  • SignalFx
  • StatsD
  • Wavefront

For this article series, we will use Prometheus as our alerting system.

Prometheus

Prometheus is an open-source monitoring and alerting system with a set of versatile capabilities. It functions as a centralized entity, adeptly accumulating, storing, and analyzing metrics derived from diverse origins. It provides comprehensive insights into system health and performance metrics, catering to the needs of technical environments.

Photo by Christian Paul Stobbe on Unsplash

Prometheus will continuously retrieve data from the given actuator endpoint collect the data and store it in a time-series database.Then users can use those data to query, send alerts or visualize them. Most of the monitoring systems already have methods to visualize the time series data that they receive. However, visualization methods are limited in capability and less configurable. Most of the time it's not sufficient enough to derive conclusions. If we want to derive complex conclusions on the performance of the system it is vital to visualize these data in a much more descriptive manner. So for this, we should connect Prometheus into a dashboard software. Dashboard software refers to applications or tools designed to visually display data and metrics in a user-friendly interface. These platforms allow users to create, customize, and view various data visualizations, charts, graphs, and tables to monitor, analyze, and interpret information from different sources. Luckily Prometheus support a few popular open-source dashboard software. Such as

  • Grafana
  • Kibana

Grafana

Grafana, a widely recognized open-source solution specializing in data visualization and analytics, stands out for its proficiency in creating dynamic dashboards. It adeptly transforms metrics obtained from platforms like Prometheus, Elasticsearch, InfluxDB, and CloudWatch into visually engaging representations.

Photo by Stephen Dawson on Unsplash

Finally, the monitoring system for the API performance will look as follows.

In the next article, I will give much more hands-on experience in setting up the spring boot actuator with Prometheus and Grafana.

If you found value in the article, please consider giving a heartfelt clap 👏 to the original author to show your appreciation for their dedication and hard work.

Connect with us on JavaToDev’s LinkedIn for more updates and lively discussions. Explore additional resources and articles on the official JavaToDev website.

Thank you for your ongoing support and here’s to another year of collaborative learning and growth in Java development!

--

--