How to monitor Spring Boot apps with Dynatrace Java OneAgent

This article explains how to use Dynatrace OneAgent to monitor Spring Boot applications in Azure Spring Cloud.

With the Dynatrace OneAgent, you can:

  • Monitor apps with the Dynatrace OneAgent.
  • Configure the Dynatrace OneAgent by using environment variables.
  • Check all monitoring data from Dynatrace dashboard.

The following video introduces Dynatrace OneAgent.


Prerequisites

Activate Dynatrace OneAgent

The following sections describe how to activate Dynatrace OneAgent.

Prepare your Azure Spring Cloud environment

  1. Create an instance of Azure Spring Cloud.
  2. Create an application that you want to report to Dynatrace by running the following command. Replace the placeholders <...> with your own values.
    az spring-cloud app create \
        --resource-group <your-resource-group-name> \
        --service <your-Azure-Spring-Cloud-name> \
        --name <your-application-name> \
        --is-public true 
    

Determine the values for the required environment variables

To activate Dynatrace OneAgent on your Azure Spring Cloud instance, you need to configure four environment variables: DT_TENANT, DT_TENANTTOKEN, DT_CONNECTION_POINT, and DT_CLUSTER_ID. For more information, see Integrate OneAgent with Azure Spring Cloud.

For applications with multiple instances, Dynatrace has several ways to group them. DT_CLUSTER_ID is one of the ways. For more information, see Customize the structure of process groups.

Add the environment variables to your application

You can add the environment variable key/value pairs to your application using either the Azure portal or the Azure CLI.

Option 1: Azure CLI

To add the key/value pairs using the Azure CLI, run the following command, replacing the placeholders <...> with the values determined in the previous steps.

az spring-cloud app deploy \
    --resource-group <your-resource-group-name> \
    --service <your-Azure-Spring-Cloud-name> \
    --name <your-application-name> \
    --jar-path app.jar \
    --env \
        DT_TENANT=<your-environment-ID> \
        DT_TENANTTOKEN=<your-tenant-token> \
        DT_CONNECTION_POINT=<your-communication-endpoint>

Option 2: Portal

To add the key/value pairs using the Azure portal, use the following steps:

  1. Navigate to the list of your existing applications.

    Screenshot of the Azure portal showing the Azure Spring Cloud Apps section.

  2. Select an application to navigate to the Overview page of the application.

    Screenshot of the application's Overview section.

  3. Select Configurations to add, update, or delete values in the Environment variables section for the application.

    Screenshot of the 'Environment variables' tab of the application's Configuration section.

Automate provisioning

Using Terraform or an Azure Resource Manager template (ARM template), you can also run a provisioning automation pipeline. This pipeline can provide a complete hands-off experience to instrument and monitor any new applications that you create and deploy.

Automate provisioning using Terraform

To configure the environment variables in a Terraform template, add the following code to the template, replacing the <...> placeholders with your own values. For more information, see Manages an Active Azure Spring Cloud Deployment.

environment_variables = {
  "DT_TENANT": "<your-environment-ID>",
  "DT_TENANTTOKEN": "<your-tenant-token>",
  "DT_CONNECTION_POINT": "<your-communication-endpoint>",
  "DT_CLUSTER_ID": "<your-cluster-ID>"
}

Automate provisioning using an ARM template

To configure the environment variables in an ARM template, add the following code to the template, replacing the <...> placeholders with your own values. For more information, see Microsoft.AppPlatform Spring/apps/deployments.

"environmentVariables": {
  "DT_TENANT": "<your-environment-ID>",
  "DT_TENANTTOKEN": "<your-tenant-token>",
  "DT_CONNECTION_POINT": "<your-communication-endpoint>",
  "DT_CLUSTER_ID": "<your-cluster-ID>"
}

View reports in Dynatrace

This section describes how to find various reports in Dynatrace.

Note

The Dynatrace menu and user interface will evolve gradually. For this reason, the dashboard may be moved to other sections in the Dynatrace website, and the following screenshots may not reflect the current version of the user interface.

After you add the environment variables to your application, Dynatrace starts collecting data. To view reports, use the Dynatrace menu, go to Services, and then select your application.

You can find the Service flow from <your-app-name>/Details/Service flow:

Screenshot of the Dynatrace 'Service flow' report.

You can find the Method hotspots from <your-app-name>/Details/Method hotspots:

Screenshot of the 'Method hotspots' report.

You can find the Database statements from <your-app-name>/Details/Response time analysis:

Screenshot of the 'Response time analysis' report and the 'Database statements' section.

Next, go to the Multidimensional analysis section.

You can find the Top database statements from Multidimensional analysis/Top database statements:

Screenshot of the 'Top database statements' report.

You can find the Exceptions overview from Multidimensional analysis/Exceptions overview:

Screenshot of the 'Exceptions overview' report.

Next, go to the Profiling and optimization section.

You can find the CPU analysis from Profiling and optimization/CPU analysis:

Screenshot of the 'CPU analysis' report.

Next, go to the Databases section.

You can find Backtrace from Databases/Details/Backtrace:

Screenshot of the Backtrace report.

View Dynatrace OneAgent logs

By default, Azure Spring Cloud will print the info level logs of the Dynatrace OneAgent to STDOUT. The logs will be mixed with the application logs. You can find the explicit agent version from the application logs.

You can also get the logs of the Dynatrace agent from the following locations:

  • Azure Spring Cloud logs
  • Azure Spring Cloud Application Insights
  • Azure Spring Cloud LogStream

You can apply some environment variables provided by Dynatrace to configure logging for the Dynatrace OneAgent. For example, DT_LOGLEVELCON controls the level of logs.

Caution

We strongly recommend that you do not override the default logging behavior provided by Azure Spring Cloud for Dynatrace. If you do, the logging scenarios above will be blocked, and the log file(s) may be lost. For example, you should not output the DT_LOGLEVELFILE environment variable to your applications.

Dynatrace OneAgent upgrade

The Dynatrace OneAgent auto-upgrade is disabled and will be upgraded quarterly with the JDK. Agent upgrade may affect the following scenarios:

  • Existing applications using Dynatrace OneAgent before upgrade will be unchanged, but will require restart or redeploy to engage the new version of Dynatrace OneAgent.
  • Applications created after upgrade will use the new version of Dynatrace OneAgent.

VNet injection instance outbound traffic configuration

For a VNet injection instance of Azure Spring Cloud, you need to make sure the outbound traffic for Dynatrace communication endpoints is configured correctly for Dynatrace OneAgent. For information about how to get communicationEndpoints, see Deployment API - GET connectivity information for OneAgent. For more information, see Customer responsibilities for running Azure Spring Cloud in VNET.

Dynatrace support model

For information about limitations when deploying Dynatrace OneAgent in application-only mode, see the Cloud application platforms section of OneAgent platform and capability support matrix.

Next steps