Monitoring and collecting data from Spring Boot

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”. We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss.

More information on: https://projects.spring.io/spring-boot/

How it works

This plugin analyzes the performance of your SprintBoot web server. It captures traffic rates, latencies and response codes of http requests sent to the web server by parsing the access log file. The plugin can optionally get global statistics (eg. the number of sessions, the number of workers, etc.) and component health status by using the Spring Boot actuator endpoint.

Installation

The plugin needs to be installed together with a CoScale agent, instructions on how to install the CoScale agent can be found here. If you want to monitor Spring Boot inside Docker containers using CoScale, check out the instructions here.

Configuration

Configure the actuator endpoint

The plugin will access the actuator metrics endpoint. To enable the actuator metrics functionality, you will need to add spring-boot-starter-actuator as a dependency to your project.

Spring Boot 1.x

In order to get the actuator metrics we require Spring MVC to expose its endpoints through HTTP. You can decide whether the endpoint will be sensitive (meaning not public and requires a user/password to access) or not. For example, add the following entries in the application.properties to customize the /metrics endpoint:

endpoints.metrics.sensitive=false
endpoints.metrics.enabled=true

Spring Boot 2.x

In 2.x Spring Boot simplifies the actuator security model by merging it with the application one and the endpoints have moved to the /actuator/metrics location. The metrics endpoint will need to be marked as exposed in your application.properties:

management.endpoints.web.exposure.include=...,metrics,...

Configure your Spring Boot access logs

Enable the Spring Boot access log format. Add the following configuration to your application.properties. The configuration differs depending on the embedded servlet container you are using.

Tomcat

server.tomcat.basedir=<log_dir>
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%v %B %D "%r" %A %a %t %H %p %U %s %S %T

Undertow

server.undertow.accesslog.dir=target/logs
server.undertow.accesslog.enabled=true
server.undertow.accesslog.pattern=%v %B %D "%r" %A %a %t %H %p %U %s %S %T
server.undertow.accesslog.prefix=access_log.
server.undertow.accesslog.rotate=true
server.undertow.accesslog.suffix=log

Jetty

server.jetty.accesslog.enabled=true
server.jetty.accesslog.append=true
server.jetty.accesslog.filename=access.log
server.jetty.accesslog.log-latency=true
server.jetty.accesslog.log-server=true

Log format

Then use this %h %v %I %u %t "%r" %s %B %D logformat for the plugin.

Active checks

The plugin will check the actuator health endpoint, to determine your application latency and health status on a per component basis.

Spring Boot 1.x:

The health endpoint can be enabled in your application.properties by the following:

endpoints.health.sensitive=false
endpoints.health.enabled=true
management.security.enabled=false

Spring Boot 2.x:

The health endpoint will need to be marked as exposed in your application.properties:

management.endpoints.web.exposure.include=...,health,...
management.endpoint.health.show-details=always

HTTP Check

This plugin can be configured to perform a HTTP GET on your Spring Boot. This active monitoring allows us to calculate the uptime of the service and the response time of the provided URL.

A full URL (eg. http://localhost/test_page) should be provided.

Metrics

Spring Boot

Name Unit Dimensions
Spring Boot active check latency s  
Spring Boot active check uptime % Component
Spring Boot active http sessions sessions  
Spring Boot datasource current usage of the connection pool # Datasource
Spring Boot datasource number of active connections connections Datasource
Spring Boot max http sessions sessions  
Spring Boot request counts requests Path, Status
Spring Boot response time s Path
Spring Boot tomcat bytes received per second b/s Source
Spring Boot tomcat bytes sent per second b/s Source
Spring Boot tomcat expired sessions sessions  

Spring Boot / JVM

Name Unit Dimensions
Spring Boot application context uptime s  
Spring Boot average system load    
Spring Boot processors count #  
Spring Boot uptime s  

Spring Boot / JVM / Classes

Name Unit Dimensions
Spring Boot loaded classes count classes  
Spring Boot total classes count classes  
Spring Boot unloaded classes count classes  

Spring Boot / JVM / GC

Name Unit Dimensions
Spring Boot GC collection count # Collector
Spring Boot GC collection time s Collector
Spring Boot gc max size of old generation memory pool b  
Spring Boot gc memory allocated b  
Spring Boot size of old generation memory pool after a full gc b  

Spring Boot / JVM / Memory

Name Unit Dimensions
Spring Boot commited heap memory b  
Spring Boot commited non heap memory b  
Spring Boot free memory b  
Spring Boot initial heap memory b  
Spring Boot initial non heap memory b  
Spring Boot jvm buffer pool memory usage b  
Spring Boot max heap memory b  
Spring Boot max non heap memory b  
Spring Boot total memory b  
Spring Boot used heap memory b  
Spring Boot used non heap memory b  

Spring Boot / JVM / Threads

Name Unit Dimensions
Spring Boot daemon thread count threads  
Spring Boot peak thread count threads  
Spring Boot thread count threads  
Spring Boot tomcat max threads threads Source
Spring Boot total started thread count threads