1

We have been working on getting dependency tracking working on Application insights using the following documentation for a Java Application:

https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-get-started?tabs=maven

https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-agent

Current versions we are using are:

  • Application Insights Agent and applicationinsights-web-auto in the POM.xml file - 2.6.1
  • MySQL connector - 5.1.31

The following files - AI-Agents.xml, ApplicationInsights.xml and applicationinsights-agent-2.6.1.jar - were added into

/home/site/wwwroot/

All the attempts below have been made on both a Window and a Linux App Service.

Locally, in the IDE (IntelliJ) when we add all these files into the resources folder and run the application with the above files configured in the VM options, dependencies are tracked without a problem. However, replicating the same configuration on the App Service displays the exception below.

Can anyone advice on whether any configurations are missing or if further configurations are required to get auto dependency tracking working please?

Thank you

2020-08-18T11:18:54.583510165Z: [ERROR]         org.apache.catalina.LifecycleException: Failed to start component [/ApplicationInsights]
2020-08-18T11:18:54.583515565Z: [ERROR]                 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
2020-08-18T11:18:54.583519665Z: [ERROR]                 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
2020-08-18T11:18:54.583523465Z: [ERROR]                 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
2020-08-18T11:18:54.583555865Z: [ERROR]                 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:744)
2020-08-18T11:18:54.583569265Z: [ERROR]                 at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:624)
2020-08-18T11:18:54.583573565Z: [ERROR]                 at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1833)
2020-08-18T11:18:54.583577365Z: [ERROR]                 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
2020-08-18T11:18:54.583581365Z: [ERROR]                 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2020-08-18T11:18:54.583585065Z: [ERROR]                 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2020-08-18T11:18:54.583588965Z: [ERROR]                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2020-08-18T11:18:54.583592665Z: [ERROR]                 at java.lang.Thread.run(Thread.java:748)

Content in Application Insights file:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings" schemaVersion="2014-05-30">
   <!-- The key from the portal: -->
   <InstrumentationKey>** Your instrumentation key **</InstrumentationKey>
   <!-- HTTP request component (not required for bare API) -->
   <TelemetryModules>
      <Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModule"/>
      <Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebSessionTrackingTelemetryModule"/>
      <Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebUserTrackingTelemetryModule"/>
   </TelemetryModules>
   <!-- Events correlation (not required for bare API) -->
   <!-- These initializers add context data to each event -->
   <TelemetryInitializers>
      <Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationIdTelemetryInitializer"/>
      <Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationNameTelemetryInitializer"/>
      <Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebSessionTelemetryInitializer"/>
      <Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserTelemetryInitializer"/>
      <Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserAgentTelemetryInitializer"/>
   </TelemetryInitializers>
</ApplicationInsights>

Content in AI-Agents file:

<ApplicationInsightsAgent>
   <Instrumentation>
      <BuiltIn enabled="true">

         <!-- capture logging via Log4j 1.2, Log4j2, and Logback, default is true -->
         <Logging enabled="true" />

         <!-- capture outgoing HTTP calls performed through Apache HttpClient, OkHttp,
              and java.net.HttpURLConnection, default is true -->
         <HTTP enabled="true" W3C="true" enableW3CBackCompat="true"/>

         <!-- capture JDBC queries, default is true -->
         <JDBC enabled="true" />

         <!-- capture Redis calls, default is true -->
         <Jedis enabled="true" />

         <!-- capture query plans for JDBC queries that exceed this value (MySQL, PostgreSQL),
              default is 10000 milliseconds -->
         <MaxStatementQueryLimitInMS>1000</MaxStatementQueryLimitInMS>

      </BuiltIn>
   </Instrumentation>
</ApplicationInsightsAgent>
Imesha
  • 11
  • 2
  • Can you make sure you have installed the agent correctly https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-agent#install-the-application-insights-agent-for-java – krishg Aug 25 '20 at 14:09
  • Also, make sure ApplicationInsights.xml is in valid location pointed by Dapplicationinsights.configurationDirectory https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-get-started?tabs=maven#add-an-applicationinsightsxml-file – krishg Aug 25 '20 at 14:12
  • @KrishnenduGhosh-MSFT - Yes the agent has been installed correctly. This is the value we have configured for JAVA_OPTS in the App Service -Dapplicationinsights.configurationDirectory="/home/site/wwwroot" javaagent:/home/site/wwwroot/applicationinsights-agent-2.6.1.jar – Imesha Aug 25 '20 at 14:41
  • Can you try by adding one more package dependency of applicationinsights-core in your POM.xml for https://mvnrepository.com/artifact/com.microsoft.azure/applicationinsights-core . Use the same version as applicationinsights-web-auto i.e. 2.6.1 – krishg Aug 26 '20 at 09:54
  • @KrishnenduGhosh-MSFT - We tried applicationinsights-core with the same version as the applicationinsights-web-auto when we attempted tracking custom telemetry, at this point we did start seeing dependency being tracked however we are still looking for a way to also include auto dependency tracking as the manual way exceeds the timeline of our project. – Imesha Aug 27 '20 at 08:23
  • No, what I meant was to add applicationinsights-core package along with applicationinsights-web-auto in your current setup to see if auto dependency collection works in deployed service. I suspected there might be missing package dependency when you deploy your app. Checking if adding explicitly helps. – krishg Aug 27 '20 at 08:30
  • @KrishnenduGhosh-MSFT - both were added as a dependency in the POM.xml file and redeployed to the App service but we are still seeing the same issue where no dependency is being auto tracked. – Imesha Aug 27 '20 at 10:31
  • one last thing I want to check is what is the logging configuration section in your app setting file. Can you please post it. – krishg Aug 28 '20 at 19:06
  • 1
    @KrishnenduGhosh-MSFT - Please see snippets of the contents from the Application Insights file and the AI-Agent file added above to my post. Are these the logging configurations you wanted to see? – Imesha Sep 04 '20 at 09:16
  • I don't see `InstrumentationKey` in your ApplicationInsights.xml file like this https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-get-started?tabs=maven#add-an-applicationinsightsxml-file . Is that something you are setting in other way like https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-get-started?tabs=maven#alternative-ways-to-set-the-instrumentation-key ? – krishg Sep 04 '20 at 19:37
  • @KrishnenduGhosh-MSFT Sorry I had only copied over a part of the file initially but please see above of the full structure of the ApplicationInsights.xml file. We have used our instrumentation key in the tag. – Imesha Sep 08 '20 at 08:52
  • Can you try setting a new app setting `CATALINA_OPTS` (similar to `JAVA_OPTS`) with value "-javaagent:D:/home/site/wwwroot/applicationinsights-agent-.jar" . Replace version with actual version of your agent e.g. 2.6.1 – krishg Sep 24 '20 at 16:14
  • https://learn.microsoft.com/azure/azure-monitor/app/java-standalone-arguments#tomcat-installed-via-download-and-unzip – krishg Sep 24 '20 at 17:33

0 Answers0