Examine Spring Boot data in Wavefront dashboards and charts

Wavefront for Spring Boot allows you to quickly configure your environment, so Spring Boot components send metrics, histograms, and traces/spans to the Wavefront service. After you’ve completed setup, you can examine the data in the Wavefront dashboards.

How to Get Data into Wavefront from Spring Boot Applications

You can send data from your Spring Boot applications into Wavefront using Micrometer with Spring Boot or Wavefront for Spring Boot:

  • Micrometer
    Wavefront supported a Micrometer integration for several years. Starting with Spring Boot 2, Micrometer is the instrumentation library powering the delivery of application metrics from Spring. This custom integration allows you to send your own metrics to Wavefront and visualize them in custom dashboards and charts. The integration uses the Wavefront Reporter for Micrometer.
  • Wavefront for Spring Boot
    Wavefront made the Wavefront for Spring Boot starter available recently. If you configure your application with the Wavefront for Spring Boot starter, you can send metrics, histograms, and traces/spans to the Wavefront service. Once the data is in Wavefront, you can view your data, find hotspots, and gather more data.
 Micrometer IntegrationWavefront for Spring Boot
Setup Set up Maven or Gradle or customize the configuration file. Auto Configuration or Custom Configuration options
Supported telemetry Metrics and histograms Metrics, histograms, and traces/spans
Ingestion options Proxy, direct ingestion Proxy, direct ingestion
Visualization Clone and customize the predefined dashboard. Create dashboards, add charts, specify metrics. Clone and customize the predefined dashboard. Create dashboards, add charts, specify metrics.
Alerts Create smart alerts that dynamically filter noise and capture true anomalies. Alerts are not available on this free cluster.
Actuator endpoint Not available. Dedicated actuator endpoint at
/actuator/wavefront to access your Wavefront dashboard.
Trial required? Yes. Sign up for a free trial. No. Use the free cluster (limited ingestion) or sign up for a trial.

Features

If you use Wavefront for Spring Boot:

  • A large number of metrics are exposed by default. See the Spring Boot documentation on Supported Metrics for details.
  • You have tracing support for all the common Spring Boot components, such as Spring MVC, Spring Web, Spring Async, Feign, Hysterix, JMS, JDBC, Mongo, Zuul, Reactor, RxJava, Redis, Logging, Spring Messaging, and RabbitMQ.
  • The spans in your applications are automatically converted to the Wavefront span format.
  • You can use Spring Cloud Sleuth or OpenTracing to send trace data.
  • If you are using OpenTracing, the logs generated by the logger in your application are automatically converted to span logs, and you can view the span logs in Wavefront Tracing Browser. You don’t need to change your code.

Getting Started

Getting started is easy:

  • If you are starting a new project, add the Wavefront dependency using https://start.spring.io.
  • If you are configuring an existing application, you only need to add a few lines to your build.

You can send data to Wavefront via direct ingestion or via Wavefront proxy. Wavefront for Spring Boot sends data to Wavefront via direct ingestion by default. Optionally, you can configure your application to send data via the Wavefront proxy.

Ways to get started with the Wavefront for Spring Boot offering

Prerequisites

  • Spring Boot 2.3.0 or above
  • Java 8 or above
  • Maven 3.3+ or Gradle 6.3 or later
    See System Requirements in the Spring Boot documentation.

Step 1: Initialize Your Project

Initialization is different for existing or new projects.

Follow these steps:

  1. Add the Wavefront dependency.

    Open your application and add the following code to your pom.xml file.

    <dependency>
      <groupId>com.wavefront</groupId>
      <artifactId>wavefront-spring-boot-starter</artifactId>
      <version>2.0.0</version>
    </dependency>
                      

    Open your application and add the following code to your build.gradle file.

    dependencies {
      ...
      implementation 'com.wavefront:wavefront-spring-boot-starter:2.0.0'
    }
                  
  2. Add the following dependency to send trace data to Wavefront using Spring Cloud Sleuth or OpenTracing.
    • Maven:
      Open your application and add the following code to your pom.xml file.

      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-sleuth</artifactId>
        <version>2.2.2.RELEASE</version>
      </dependency>
                        
    • Gradle:
      Open your application and add the following code to your build.gradle file.

      dependencies {
        ...
        implementation 'org.springframework.cloud:spring-cloud-starter-sleuth:2.2.2.RELEASE'
      }
                        
    • Maven:
      Open your application and add the following code to your pom.xml file. The logs generated by the logger in your application will be automatically converted to span logs, and you can view the span logs in the Wavefront Tracing Browser.

      <dependency>
        <groupId>io.opentracing.contrib</groupId>
        <artifactId>opentracing-spring-cloud-starter</artifactId>
        <version>0.5.3</version>
      </dependency>
                    
    • Gradle:
      Open your application and add the following code to your build.gradle file.

      dependencies {
        ...
        implementation 'io.opentracing.contrib:opentracing-spring-cloud-starter:0.5.3'
      }
                    

Follow these steps:

  1. Navigate to https://start.spring.io.
  2. Define the project name, Spring version, and other parameters.
    Spring Initializr
  3. Click Add dependency, select Wavefront from the dependency list, and click Generate.
    Wavefront dependency
  4. Add the following dependency to send trace data to Wavefront using Spring Cloud Sleuth or OpenTracing.
    • Maven:
      Open your application and add the following code to your pom.xml file.

      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-sleuth</artifactId>
        <version>2.2.2.RELEASE</version>
      </dependency>
                          
    • Gradle:
      Open your application and add the following code to your build.gradle file.

      dependencies {
        ...
        implementation 'org.springframework.cloud:spring-cloud-starter-sleuth:2.2.2.RELEASE'
      }
                          
    • Maven:
      Open your application and add the following code to your pom.xml file. The logs generated by the logger in your application will be automatically converted to span logs, and you can view the span logs in the Wavefront Tracing Browser.

      <dependency>
        <groupId>io.opentracing.contrib</groupId>
        <artifactId>opentracing-spring-cloud-starter</artifactId>
        <version>0.5.3</version>
      </dependency>
                      
    • Gradle:
      Open your application and add the following code to your build.gradle file.

      dependencies {
        ...
        implementation 'io.opentracing.contrib:opentracing-spring-cloud-starter:0.5.3'
        }
                      
  5. Add the application logic and start the project.
    You need a tracing application to view the trace data in Wavefront, else some of the charts will not show data.

Step 2: View Your Data on Wavefront

To view your data, you first run your project and then click the link that directs you to Wavefront. Follow these steps:

  1. Run your project.
    ./mvnw spring-boot:run
             
    ./gradlew bootRun
             

    You see the following printed on your console:
    Example:

         To share this account, make sure the following is added to your configuration:
    
          management.metrics.export.wavefront.api-token=44444-34this-45is-123a-sampletoken
          management.metrics.export.wavefront.uri=https://wavefront.surf
    
         Connect to your Wavefront dashboard using this one-time use link:
         https://wavefront.surf/us/example
    
  2. Add data to your application before you start to view the data on Wavefront.
  3. Click the link (https://wavefront.surf/us/<name>) and you are taken to the Wavefront Service dashboard where you can examine the data sent by your application.

Optional: Custom Configurations

Add the following custom configurations to the application.properties file.

  • Invite users and let them send data to the same cluster

    1. Click the link that was printed on your console and navigate to the Wavefront Service dashboard:
      1. Click the gear icon and select Account Management.
      2. Click Invite New Users and specify a comma-separated list of email addresses.
        Invite Users The users will get an email with a link to reset their password. They can then access your dashboard.
    2. Information about the token and URL are displayed on your terminal. Add them to your project’s application.properties file.
       management.metrics.export.wavefront.api-token=<Enter_Token>
       management.metrics.export.wavefront.uri=https://wavefront.surf
      
    3. If you are using the freemium account and want the single-use login URL to show on the terminal each time you start the application, add wavefront.freemium-account to the application.properties file and set it to true.
        wavefront.freemium-account=true
      
    4. Restart your application.
  • Send data to Wavefront using the Wavefront proxy

    Copy and paste the following property.

    management.metrics.export.wavefront.uri=http://<Proxy_Host>:2878
    
  • Use the Wavefront Actuator endpoint to access the dashboard

    If you have a web app, you can expose the Wavefront Actuator endpoint at /actuator/wavefront to access your Wavefront dashboard.
    Example:

    management.endpoints.web.exposure.include=health,info,...,wavefront
    
  • Specify application and service names

    If you have more than one Spring Boot application, you can specify the names of the application and the service in the application.properties file.
    Example:

      wavefront.application.name=my-application
      wavefront.application.service=my-service
    

    Example: If you are using a YAML file.

      wavefront:
        application:
          name: my-application
          service: my-service 
    

    Optionally:

    • If you configured spring.application.name in your application, it is automatically used as the service name. You can configure the cluster and shard the same way. This information is used to tag metrics and traces.
    • If you want to take full control over ApplicationTags, you can create a @Bean.
    • If you want to customize the instance that is auto-configured, add an ApplicationTagsBuilderCustomizer bean.
  • Disable integration tests from sending data to Wavefront

    Add management.metrics.export.wavefront.enabled to your integration tests and set it to false to stop it from sending data to Wavefront.

    Example: Disable all integration tests from sending data to Wavefront by updating the application.properties file.

    management.metrics.export.wavefront.enabled=false
    

    Example: Disable a specific integration test from sending data to Wavefront.

    package com.example.demo;
    
    import org.junit.jupiter.api.Test;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.test.context.TestPropertySource;
    
    @TestPropertySource(properties = "management.metrics.export.wavefront.enabled=false")
    @SpringBootTest
    class DemoApplicationTests {
    
    	@Test
    	void contextLoads() {
    	}
    
    }
    

Next Steps