Codeless Java Application Monitoring using Azure Monitor Application Insights

[As of November 6, 2020]

Recently a new feature of Azure Monitor Application Insights got generally available. This feature allows us to monitor Java applications in a non-invasive manner. Indeed this feature has been already available in APM (Application Performance Management) tools such as AppDynamics, Dynatrace, New Relic, and so on. In case of Application Insights 2.x, however, embedding some codes implemented with SDK could be required to send telemetry data or dependencies to Application Insights.

Documents for this feature are available in the following URL.

Java codeless application monitoring Azure Monitor Application Insights
https://docs.microsoft.com/azure/azure-monitor/app/java-in-process-agent

When following the procedure listed below, we can try it easily.

  1. Create Application Insights instance.
  2. Copy a connection string containing a instrumentation key from “overview” page of Application Insights.
  3. Create a file named “ApplicationInsights.json” and write down the connection string in the form of JSON (see below).
{
  "instrumentationSettings": {
    "connectionString": "InstrumentationKey=00000000-0000-0000-0000-000000000000"
  }
}
  1. Download agent JAR file. Download link is in the document.
  2. Locate downloaded agent JAR file and ApplicationInsights.json in the same directory.
  3. Start Java application with the following argument.
java -javaagent:path/to/applicationinsights-agent-3.0.0.jar path/to/app.jar

For more details, please check the following wiki pages.

Configuration options – Java standalone agent for Azure Monitor Application Insights
https://docs.microsoft.com/azure/azure-monitor/app/java-standalone-config
Autocollected requests, dependencies, logs, and metrics
https://docs.microsoft.com/azure/azure-monitor/app/java-in-process-agent#autocollected-requests-dependencies-logs-and-metrics
Configuring JVM args Java standalone agent for Azure Monitor Application Insights
https://docs.microsoft.com/azure/azure-monitor/app/java-standalone-arguments

In this entry, I used this feature to monitor applications running on WebLogic Server 14.1.1 and built with Helidon SE/MP.

WebLogic Server 14.1.1

There are several ways to ingest the agent. In this example, I modified <Domain_Home>/bin/setDomainEnv.sh. I used “medrec-spring” sample application, which was bundled with WebLogic Server. After playing the application for a while, I could see the following images on “Application Map”.

When clicking “SQL” on this application map, queries called from WebLogic Server were listed (see below).

When clicking “investigate performance”, I could see performance view of queries. Choosing one of queries from the list and clicking “(2) Samples”, I could see sample dependencies.

To see end-to-end transaction details, click one of sample dependencies. In this case, I clicked the suggested sample dependency.

If user flow is required, click “Show what happened before and after this dependency in User Flows” in Related Items section.

Helidon SE/MP

I created two Docker containers. One of them contains a Java application built with Helidon SE, and another one contains a Java application built with Helidon MP. Each container runs on App Service. If you are not familiar with Helidon, please check the following URL.

Project Helidon
https://helidon.io/

When creating a Docker image, the agent file and ApplicationInsights.json are required to bundle with the Java application, and argument “-javaagent:…” should be specified to CMD or ENTRYPOINT in Dockerfile (see below).

...
CMD ["java", "-javaagent:applicationinsights-agent-3.0.0.jar", "-jar", "helidon-quickstart-se.jar"]
...

In this entry, “SE” stands for a Java application built with Helidon SE, and “MP” stands for a Java application built with Helidon MP. SE hosts some APIs which pass HTTP request to MP.

Unhandled exception

I checked whether it could monitor exceptions. In this example, URL for “MP” should be provided via environment variable, but I invoked APIs hosted on SE without URL for MP provided. An exception occurred but it was not caught and handled in API codes intentionally.

I could see an unhandled exception in SE on “End-to-end transaction details” page. As you could see in the screenshot below, this feature can also monitor any Java applications running not only in cloud but also on premises.

Dependencies

I invoked APIs on SE several times. After a while, I could see the following application map. This application map told me that SE (helidon-se-quickstart) called MP (helidon-mp-quickstart).

I clicked circle “helidon-se-quickstart”, and then clicked yellow-marked “investigate performance”.

Choosing “Dependencies” tab, I could see an API hosted on SE was called three times.

To check end-to-end transaction, I clicked [(3) samples] and clicked one of samples appeared in the righthand. Regarding a sample, I chose a suggested one (yellow-marked).

When clicking the sample, I could see end-to-end transaction details, which you might often see in APM tools.

Conclusion

Your feedback would be much appreciated. Sample applications (Helidon SE/MP) used here are available on GitHub.

Codeless Java Application Monitoring using Azure Monitor Application Insights
https://github.com/anishi1222/Codeless-Java-Application-Monitoring-using-Azure-Monitor-Application-Insights

Isseus
https://github.com/microsoft/ApplicationInsights-Java/issues

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト /  変更 )

Google フォト

Google アカウントを使ってコメントしています。 ログアウト /  変更 )

Twitter 画像

Twitter アカウントを使ってコメントしています。 ログアウト /  変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト /  変更 )

%s と連携中