Lesson 1: Fundamentals of Monitoring with Boot

1. Module 8 Overview

This module is all about monitoring your API and tracking good, useful metrics from the start.

It's also a Spring Boot heavy lesson - mainly because the framework makes the Ops story a lot better and saves us time and effort in having to implement this low level support ourselves. And while this isn't a Spring Boot focused module, we do want to use the best tool for the job.

2. Goals

Learn how Spring Boot makes monitoring and tracking the metrics of a Spring API very easy.

3. Lesson Notes

The relevant module you need to import when you're starting with this lesson is: m8-lesson1-start
If you want to skip and see the complete implementation, feel free to jump ahead and import: m8-lesson1

For the Spring 5 version of these projects, you can use the module8-springboot2 branch: m8-lesson1-start and m8-lesson1

We are going to use Spring Boot actuators to start tracking metrics and expose these via several endpoints:

  • /info
  • /health
  • /metrics

We are also going to configure these endpoints via application.properties:

- "endpoints.{endpointname}.{option}" - with the following options:

  • id
  • sensitive
  • enabled

- ex: endpoints.health.sensitive=false

- other endpoint related options can be configured as well:
management.context-path = actuators
management.port = 8081

/info endpoint configuration

info.app.name = My App
info.build.version = @[email protected]

Note how we are using the @@ syntax here to get the value of the property from the pom of the parent (after maven runs package)

URLs for a local deployment



Note that the assumption here is that the deployment happens via Spring Boot (where the port is already configured to 8081 and the app will be deployed at the root). If deployment happens in a standard Tomcat server, then these URLs will be slightly different.

4. Resources

- Spring Boot Actuator: Production-ready features (the reference)

- Building a RESTful Web Service with Spring Boot Actuator (official guide)

- Spring Boot Actuator (my article)

- The Module 8 Branch of the project on Github

RwS - Fundamentals of Monitoring with Boot - transcript.pdf