Send Spring Boot Metrics into InfluxDB and Grafana

One of the notable Spring Boot 2 features is the introduction of micrometer (SLF4J for application metrics).

Spring Boot ships with a whole series of built-in metrics collecting JVM metrics  (memory usage, garbage collection, threads, and classes), CPU usage, Tomcat metrics as well as others.

You can query the metrics using the actuator HTTP endpoint:

Please note that you need to authenticate if Spring Security is present.

Install InfluxDB and Grafana using Docker Compose

A simple way to run InfluxDB and Grafana locally is Docker Compose.

Start InfluxDB and Grafana with docker-compose up .

Grafana is now running on http://localhost:3000. The default user is admin/admin.

Send Spring Boot Metrics to InfluxDB

Micrometer can send metrics to a series of destination using just configuration. You’ll only need to add the specific dependency and a few configuration values.

Grafana Configuration

The missing pieces to get Grafana up and running are:

  1. Log in and change the admin password.
  2. Add the InfluxDB data source. (host: http://boot-influxdb:8086, credentials as in the docker-compose.yml)
  3. Create a Dashboard.

The last step would require a separate blog post. The result however might look like this:

Leave a Reply

Your email address will not be published. Required fields are marked *

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