| title | Configure APM Platforms for Tomcat, JBoss, or Java SE Apps | |||||
|---|---|---|---|---|---|---|
| description | Learn how to configure APM platforms, such as Application Insights, New Relic, and AppDynamics, for Tomcat, JBoss, or Java SE app on Azure App Service. | |||||
| keywords | azure app service, web app, windows, oss, java, tomcat, jboss, spring boot, quarkus | |||||
| ms.devlang | java | |||||
| ms.topic | how-to | |||||
| ms.date | 07/17/2024 | |||||
| zone_pivot_groups | app-service-java-hosting | |||||
| adobe-target | true | |||||
| author | cephalin | |||||
| ms.author | cephalin | |||||
| ms.service | azure-app-service | |||||
| ms.custom |
|
This article shows how to connect Java applications deployed on Azure App Service with Azure Monitor Application Insights, NewRelic, and AppDynamics application performance monitoring (APM) platforms.
[!INCLUDE java-variants]
Azure Monitor Application Insights is a cloud native application monitoring service that enables customers to observe failures, bottlenecks, and usage patterns to improve application performance and reduce mean time to resolution (MTTR). With a few clicks or CLI commands, you can enable monitoring for your Node.js or Java apps, autocollecting logs, metrics, and distributed traces, eliminating the need for including an SDK in your app. For more information about the available app settings for configuring the agent, see the Application Insights documentation.
To enable Application Insights from the Azure portal, go to Application Insights on the left-side menu and select Turn on Application Insights. By default, a new application insights resource of the same name as your web app is used. You can choose to use an existing application insights resource, or change the name. Select Apply at the bottom.
To enable via the Azure CLI, you need to create an Application Insights resource and set a couple app settings on the Azure portal to connect Application Insights to your web app.
-
Enable the Applications Insights extension
az extension add -n application-insights -
Create an Application Insights resource using the following CLI command. Replace the placeholders with your desired resource name and group.
az monitor app-insights component create --app <resource-name> -g <resource-group> --location westus2 --kind web --application-type webNote the values for
connectionStringandinstrumentationKey, you'll need these values in the next step.[!NOTE] To retrieve a list of other locations, run
az account list-locations. -
Set the instrumentation key, connection string, and monitoring agent version as app settings on the web app. Replace
<instrumentationKey>and<connectionString>with the values from the previous step.az webapp config appsettings set -n <webapp-name> -g <resource-group> --settings "APPINSIGHTS_INSTRUMENTATIONKEY=<instrumentationKey>" "APPLICATIONINSIGHTS_CONNECTION_STRING=<connectionString>" "ApplicationInsightsAgent_EXTENSION_VERSION=~3" "XDT_MicrosoftApplicationInsights_Mode=default"az webapp config appsettings set -n <webapp-name> -g <resource-group> --settings "APPINSIGHTS_INSTRUMENTATIONKEY=<instrumentationKey>" "APPLICATIONINSIGHTS_CONNECTION_STRING=<connectionString>" "ApplicationInsightsAgent_EXTENSION_VERSION=~3" "XDT_MicrosoftApplicationInsights_Mode=default" "XDT_MicrosoftApplicationInsights_Java=1"
To configure New Relic:
::: zone pivot="java-jboss"
Note
The latest New Relic documentation lists JBoss EAP support up to 7.x. JBoss EAP 8.x is not yet supported.
::: zone-end
-
Create a NewRelic account at NewRelic.com
-
Copy your license key, you need it to configure the agent later.
-
SSH into your App Service instance and create a new directory /home/site/wwwroot/apm.
-
Upload the unpacked NewRelic Java agent files into a directory under /home/site/wwwroot/apm. The files for your agent should be in /home/site/wwwroot/apm/newrelic.
-
Modify the YAML file at /home/site/wwwroot/apm/newrelic/newrelic.yml and replace the placeholder license value with your own license key.
-
In the Azure portal, browse to your application in App Service and create a new Application Setting.
::: zone pivot="java-javase,java-jboss"
Create an environment variable named
JAVA_OPTSwith the value-javaagent:/home/site/wwwroot/apm/newrelic/newrelic.jar.::: zone-end
::: zone pivot="java-tomcat"
Create an environment variable named
CATALINA_OPTSwith the value-javaagent:/home/site/wwwroot/apm/newrelic/newrelic.jar.::: zone-end
-
Create a NewRelic account at NewRelic.com
-
Download the Java agent from NewRelic. It has a file name similar to newrelic-java-x.x.x.zip.
-
Copy your license key, you need it to configure the agent later.
-
SSH into your App Service instance and create a new directory /home/site/wwwroot/apm.
-
Upload the unpacked NewRelic Java agent files into a directory under /home/site/wwwroot/apm. The files for your agent should be in /home/site/wwwroot/apm/newrelic.
-
Modify the YAML file at /home/site/wwwroot/apm/newrelic/newrelic.yml and replace the placeholder license value with your own license key.
-
In the Azure portal, browse to your application in App Service and create a new Application Setting.
::: zone pivot="java-javase"
Create an environment variable named
JAVA_OPTSwith the value-javaagent:/home/site/wwwroot/apm/newrelic/newrelic.jar.::: zone-end
::: zone pivot="java-tomcat"
Create an environment variable named
CATALINA_OPTSwith the value-javaagent:/home/site/wwwroot/apm/newrelic/newrelic.jar.::: zone-end
::: zone pivot="java-javase,java-jboss"
Note
If you already have an environment variable for JAVA_OPTS, append the -javaagent:/... option to the end of the current value.
::: zone-end
::: zone pivot="java-tomcat"
Note
If you already have an environment variable for CATALINA_OPTS, append the -javaagent:/... option to the end of the current value.
::: zone-end
To configure AppDynamics:
-
Create an AppDynamics account at AppDynamics.com
-
Download the Java agent from the AppDynamics website. The file name is similar to AppServerAgent-x.x.x.xxxxx.zip
-
SSH into your App Service instance and create a new directory /home/site/wwwroot/apm.
-
Upload the Java agent files into a directory under /home/site/wwwroot/apm. The files for your agent should be in /home/site/wwwroot/apm/appdynamics.
-
In the Azure portal, browse to your application in App Service and create a new Application Setting.
::: zone pivot="java-javase"
Create an environment variable named
JAVA_OPTSwith the value-javaagent:/home/site/wwwroot/apm/appdynamics/javaagent.jar -Dappdynamics.agent.applicationName=<app-name>where<app-name>is your App Service name. If you already have an environment variable forJAVA_OPTS, append the-javaagent:/...option to the end of the current value.::: zone-end
::: zone pivot="java-tomcat"
Create an environment variable named
CATALINA_OPTSwith the value-javaagent:/home/site/wwwroot/apm/appdynamics/javaagent.jar -Dappdynamics.agent.applicationName=<app-name>where<app-name>is your App Service name. If you already have an environment variable forCATALINA_OPTS, append the-javaagent:/...option to the end of the current value.::: zone-end
::: zone pivot="java-jboss"
::: zone-end
-
Create an AppDynamics account at AppDynamics.com
-
Download the Java agent from the AppDynamics website. The file name is similar to AppServerAgent-x.x.x.xxxxx.zip
-
Use the Kudu console to create a new directory /home/site/wwwroot/apm.
-
Upload the Java agent files into a directory under /home/site/wwwroot/apm. The files for your agent should be in /home/site/wwwroot/apm/appdynamics.
-
In the Azure portal, browse to your application in App Service and create a new Application Setting.
::: zone pivot="java-javase"
Create an environment variable named
JAVA_OPTSwith the value-javaagent:/home/site/wwwroot/apm/appdynamics/javaagent.jar -Dappdynamics.agent.applicationName=<app-name>where<app-name>is your App Service name. If you already have an environment variable forJAVA_OPTS, append the-javaagent:/...option to the end of the current value.::: zone-end
::: zone pivot="java-tomcat"
Create an environment variable named
CATALINA_OPTSwith the value-javaagent:/home/site/wwwroot/apm/appdynamics/javaagent.jar -Dappdynamics.agent.applicationName=<app-name>where<app-name>is your App Service name. If you already have an environment variable forCATALINA_OPTS, append the-javaagent:/...option to the end of the current value.::: zone-end
The configuration options are different depending on which Datadog site your organization is using. See the official Datadog Integration for Azure Documentation
The configuration options are different depending on which Datadog site your organization is using. See the official Datadog Integration for Azure Documentation
Dynatrace provides an Azure Native Dynatrace Service. To monitor Azure App Services using Dynatrace, see the official Dynatrace for Azure documentation
Dynatrace provides an Azure Native Dynatrace Service. To monitor Azure App Services using Dynatrace, see the official Dynatrace for Azure documentation
Visit the Azure for Java Developers center to find Azure quickstarts, tutorials, and Java reference documentation.