Monitoring Spring Boot applications with Prometheus and LOGIQ

Monitoring Spring Boot applications with Prometheus and LOGIQ

Spring Boot is a Spring module that combines embedded servers with the Spring Framework. It enables rapid application development on the Spring framework and provides a simpler and faster way to set up, configure, and run simple and web-based applications. You can use Sprint Boot to create stand-alone Spring-based applications that require minimal configuration.

In this article, we’ll take a look at how you can monitoring your Spring Boot applications using Spring Boot Actuator, Micrometer, Prometheus, and LOGIQ.

Spring Boot Actuator and Micrometer

Spring Boot Actuator is a sub-project of Spring Boot that adds several production-grade services to your application with little effort on your part. It exposes various operational information about the running application – health, metrics, audit entries, scheduled tasks, env settings, etc. You can query the data via several HTTP endpoints. In this guide, we discuss how to enable API and other metrics using Actuator and micrometer. Micrometer provides a simple facade over the instrumentation clients for the most popular monitoring systems, allowing you to instrument your JVM-based application code without vendor lock-in. Think SLF4J, but for metrics.

Enabling Actuator and Micrometer dependencies

In Spring Boot’s pom.xml file, add the Spring Boot Actuator and Micrometer dependencies to enable Prometheus monitoring, as shown below.

// Enable Actuator dependency
// Enable Micrometer Prometheus dependency

Next, in Spring Boot’s file, add the following line.

// Enable Actuator Endpoints in

Restart the server and navigate to http://localhost:<port>/actuator/ to verifiy if the Actuator endpoints are enabled.

Navigate to http://localhost:<port>/actuator/prometheus and verify if your Prometheus metrics are being displayed.

Enable API Timings

Micrometer comes with a timed annotation. Annotate Spring Controller methods with the@Timedannotation, as shown below.

Restart the server, invoke your APIs a few times and navigate to http://localhost:<port>/actuator/prometheus. The browser will now display API stats along with other metrics.

Once these metrics are available, you can use LOGIQ to visualize them and set up alerts for important events. The following image depicts an example of Spring Boot monitoring dashboard built by visualizing metrics ingested into LOGIQ via Prometheus.

Related articles

Observability Best Practices

The term “observability” has gone viral in the cloud industry, at least among IT professionals.

Gathering logs from Google Autopilot

In any modern containerized workload setting, container orchestration is imperative. Purportedly, the majority of contemporary

The LOGIQ blog

Let’s keep this a friendly and inclusive space: A few ground rules: be respectful, stay on topic, and no spam, please.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More insights. More affordable.
Less hassle.