Recent Tutorials and Articles
    Exporting Spring Boot Actuator Metrics to ElasticSearch
    Published on: 2019-01-20 08:01:16
    Posted By: Amit Kumar

    This tutorial describes how to export Spring Boot actuator metrics to ElasticSearch and then visualize those using Kibana.

    Abstract


    Spring Boot is most popular framework for developing Microservices in Java. One of the reason for same is support for production ready endpoints for metrics, project info, taking heap/thread dumps etc. through Spring Actuator library.

    In this article, we will see how to export these Spring Boot Actuator collected metrics to ElasticSearch.

     

    Pre-requisites


    1. Microservices with Spring Boot Version 2.1.0 or newer
    2. Running Cluster of ElasticSearch. In this tutorial, we have used version 6.5.3

     

    Exporting Metrics to ElasticSearch


    Spring boot uses Actuator library to collect and expose JVM, server and other metrics. Hence, first step is to add Spring Boot Actuator starter to your pom.xml. Specifically, add following dependency to dependencies section of your pom.xml -

    <dependency>
    	<groupId>org.springframework.boot</groupId>
    	<artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

     

    Spring Boot Actuator has started using Micrometer as metrics facade. This simplifies and standardizes application metrics and allows exporting of metrics to various stores such as Elasticsearch, Graphite etc. without any changes in Spring Boot application.

    Next step is to add following Micrometer dependency to export data into Elasticsearch -

    <dependency>
    	<groupId>io.micrometer</groupId>
    	<artifactId>micrometer-registry-elastic</artifactId>
    </dependency>

    Since we are now all wired up, we will now need to configure our Elasticsearch host using following property -

    management.metrics.export.elastic.host=http://<elastic-host>:<elastic-port>

     

    That's all! Once you start your service, you should start getting its metrics data into ElasticSearch cluster.

    Thank you for reading through the tutorial. In case of any feedback/questions/concerns, you can communicate same to us through your comments and we shall get back to you as soon as possible.

    Posted By: Amit Kumar
    Published on: 2019-01-20 08:01:16

    Comment Form is loading comments...