Codeless Java Application Monitoring using Azure Monitor Application Insights
[As of January 31, 2021]
Last year one feature of Azure Monitor Application Insights was introduced. 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
When following the procedure listed below, we can try it easily.
- Create Application Insights instance.
- Copy a connection string containing a instrumentation key from “overview” page of Application Insights.
- Create a file named “ApplicationInsights.json” and write down the connection string in the form of JSON (see below).
- Download the agent JAR file. Download link is in the document. The latest one is 3.0.2 as of January 31, 2021.
- Locate downloaded agent JAR file and ApplicationInsights.json in the same directory.
- Start your Java application with the following argument.
java -javaagent:path/to/applicationinsights-agent-3.0.2.jar path/to/app.jar
For more details, please check the following documents.
Configuration options — Java standalone agent for Azure Monitor Application Insights
Autocollected requests, dependencies, logs, and metrics
Configuring JVM args Java standalone agent for Azure Monitor Application Insights
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.
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.
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 at CMD or ENTRYPOINT in Dockerfile (see below).
CMD ["java", "-javaagent:applicationinsights-agent-3.0.2.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.
I checked whether the application 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 neither caught nor 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.
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.
As I mentioned earlier, this feature is a public preview. your feedback would be much appreciated. For your convenience, sample applications are available on GitHub.