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.

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 Traces Browser. You don’t need to change your code.

Sending Data From Spring Boot Into Wavefront

You can send data from your Spring Boot applications into Wavefront using the Wavefront for Spring Boot Starter (all users) or the Wavefront Spring Boot integration (Wavefront customers and trial users).

  • Wavefront for Spring Boot Starter
    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.
    • Freemium All users can run the Spring Boot Starter with the default settings to view their data in the Wavefront Freemium instance. Certain limitations apply, for example, alerts are not available, but you don’t have to sign up.
    • Wavefront Customer or Trial User Wavefront customers or trial users can modify the default Wavefront Spring Boot Starter to send data to their cluster. You can sign up for a free 30-day trial here.
  • Wavefront Spring Boot Integration Wavefront customers and trial users can access the Wavefront Spring Boot integration directly from their clusters.

Dashboards

After you’ve completed setup, you can examine the data in the Wavefront dashboards.

The Spring Boot Inventory dashboard provides real-time visibility into your Spring Boot environment.
  • This is the default dashboard when you run the Spring Boot initializer.
  • You can also access this dashboard from the Spring Boot integration's Dashboards tab.
screenshot of spring boot dashboard
The Wavefront Traces Browser allows you to examine traces for your application(s). You can access this browser if trace data are flowing:
  • From the Spring Boot Inventory dashboard.
  • From the Spring Boot integration's Dashboards tab.
Tracing section has link to Application Dashboard
screenshot of the traces browser

Getting Started

Getting started is easy. Here are some things to know before you start:

Prerequisites for Wavefront Spring Boot Starter

  • Spring Boot 2.3.0 or above
    Wavefront for Spring Boot VersionSpring Boot Version
    2.0.1 2.3.x
  • Java 8 or above
  • Maven 3.3+ or Gradle 6.3 or later
    See System Requirements in the Spring Boot documentation.

Step 1: Initialize and Configure Your Project

Initialize a new project using the Spring Initializer or add the required dependencies to an existing Spring projects to start sending data to Wavefront.

Follow these steps:

  1. Navigate to https://start.spring.io.
  2. Select Spring 2.3.0 or later as the Spring Boot version and define the other parameters for your project.
    Spring Initializr
  3. Click Add dependency and select Wavefront from the dependency list.
    Wavefront dependency
  4. Optionally, to send trace data to Wavefront, add Spring Cloud Sleuth as a dependency.
    Slueth dependency
  5. Click Generate to download the project as a zip file.
  6. Open the project, add the application logic, and start the project.

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>
    </dependency>
                      

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

    dependencies {
      ...
      implementation 'com.wavefront:wavefront-spring-boot-starter:$releaseVersion'
    }
                  
  2. Import the Wavefront for Spring Boot Bill of Materials (BOM) to your project.
    
    <dependencyManagement>
      <dependencies>
      .....
        <dependency>
          <groupId>com.wavefront</groupId>
          <artifactId>wavefront-spring-boot</artifactId>
          <version>$releaseVersion</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
      .....  
      </dependencies>
    </dependencyManagement>
                    

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

    dependencyManagement {
      imports {
        mavenBom "com.wavefront:wavefront-spring-boot-bom:$releaseVersion"
      }
    }
                
  3. If you want to send trace data to Wavefront using Spring Cloud Sleuth or OpenTracing, add the following dependencies.
    • Maven
      1. 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>
        </dependency>
                          
      2. Import the Spring Cloud Bill of Materials (BOM) to your project.
        <dependencyManagement>
          <dependencies>
          .....
            <dependency>
              <groupId>org.springframework.cloud</groupId>
              <artifactId>spring-cloud-dependencies</artifactId>
              <version>$springCloudVersion</version>
              <type>pom</type>
              <scope>import</scope>
            </dependency>
          .....
          <dependencies>
        <dependencyManagement>
                            
    • Gradle
      1. Open your application and add the following code to your build.gradle file.
        dependencies {
          ...
          implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
        }
                          
      2. Import the Spring Cloud Bill of Materials (BOM) to your project. Add the following code under <dependencyManagement>.
        dependencyManagement {
          imports {
            ...
            mavenBom "org.springframework.cloud:spring-cloud-dependencies:$springCloudVersion"
        }
                            
    • 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 Traces Browser.

      <dependency>
        <groupId>io.opentracing.contrib</groupId>
        <artifactId>opentracing-spring-cloud-starter</artifactId>
        <version>0.5.7</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.7'
      }
                    

Step 2 (Optional): Specify Your Wavefront Instance

By default, the Wavefront Spring Boot Starter creates an account for you and sends data to the Freemium instance. If you already have a Wavefront account, you can send data there instead by specifying the uri and api-token properties, as follows:

management.metrics.export.wavefront.api-token=$API_Token
management.metrics.export.wavefront.uri=$wavefront_instance

Step 3: View Your Data on Wavefront

To view your data, you first run your project from the command line, 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:
    The following example shows what you see if you’re using the Freemium instance:

         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 (for example, https://wavefront.surf/us/<name>) and you are taken to the Wavefront Spring Boot Inventory dashboard where you can examine the data sent by your application.
    Example: Spring Boot metrics dashbaord If your application uses trace data, click the link in the Tracing section of the dashboard to be directed to the Wavefront Traces Browser.
    Example: Spring Boot traces browser

Custom Configurations

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

Invite Users

You can 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.

Use the Wavefront Proxy

The Wavefront proxy ingests data and forwards them to the Wavefront service in a secure, fast, and reliable manner. It prevents data loss, simplifies firewall configuration, and allows you to filter or enrich data before they arrive at the Wavefront service.

Copy and paste the following property.

management.metrics.export.wavefront.uri=proxy://<Proxy_Host>:2878

Access the Dashboard with the Actuator Endpoint

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.

Wavefront Spring Boot Integration

If you already have a Wavefront account, you can start the setup and examine the dashboards from the Wavefront Spring Boot integration. This is supported for Wavefront trial accounts.

  1. Log in to your Wavefront instance.
  2. Select Integrations, search for Spring Boot, and select the Spring Boot integration.
  3. Use the information in the Setup tab to set up the integration.
  4. When setup is complete, click the Dashboard tab to examine your data.

Next Steps