Get Started (Supplemental)

In the following sections, learn how to get Java autoinstrumentation for specific technical environments.

Azure App Service

For more information, see Application monitoring for Azure App Service and Java.

Azure Functions

For more information, see Monitoring Azure Functions with Azure Monitor Application Insights.

Azure Spring Apps

For more information, see Use Application Insights Java In-Process Agent in Azure Spring Apps.

Containers

Note

With Spring Boot Native Image applications, use the Azure Monitor OpenTelemetry Distro / Application Insights in Spring Boot native image Java application project instead of the Application Insights Java agent.

Docker entry point

If you're using the exec form, add the parameter -javaagent:"path/to/applicationinsights-agent-.jar" to the parameter list somewhere before the "-jar" parameter, for example:

ENTRYPOINT ["java", "-javaagent:path/to/applicationinsights-agent-.jar", "-jar", "<myapp.jar>"]

If you're using the shell form, add the Java Virtual Machine (JVM) arg -javaagent:"path/to/applicationinsights-agent-.jar" somewhere before -jar, for example:

ENTRYPOINT java -javaagent:"path/to/applicationinsights-agent-.jar" -jar <myapp.jar>

Docker file

A Dockerfile example:

FROM ...

COPY target/*.jar app.jar

COPY agent/applicationinsights-agent-.jar applicationinsights-agent-.jar 

COPY agent/applicationinsights.json applicationinsights.json

ENV APPLICATIONINSIGHTS_CONNECTION_STRING="CONNECTION-STRING"
        
ENTRYPOINT["java", "-javaagent:applicationinsights-agent-.jar", "-jar", "app.jar"]

In this example, you copy the applicationinsights-agent-.jar and applicationinsights.json files from an agent folder (you can choose any folder of your machine). These two files have to be in the same folder in the Docker container.

Partner container images

If you're using a partner container image that you can't modify, mount the Application Insights Java agent jar into the container from outside. Set the environment variable for the container JAVA_TOOL_OPTIONS=-javaagent:/path/to/applicationinsights-agent.jar.

Spring Boot

For more information, see Using Azure Monitor Application Insights with Spring Boot.

Java Application servers

For information on setting up the Application Insights Java agent, see Enabling Azure Monitor OpenTelemetry for Java.

See the Application server configuration in the OpenTelemetry Java agent documentation for tips on how to configure the -javaagent for various Java Application Servers. In all of the examples, you will use -javaagent:/path/to/applicationinsights-agent.jar instead of -javaagent:/path/to/opentelemetry-javaagent.jar.