시작(보충)

다음 섹션에서는 특정 기술 환경에 대한 Java 자동 계측을 가져오는 방법을 알아봅니다.

Azure App Service

자세한 내용은 Azure App Service 및 Java에 대한 애플리케이션 모니터링을 참조하세요.

Azure 기능

자세한 내용은 Azure Monitor Application Insights로 Azure Functions 모니터링을 참조하세요.

Azure Spring Apps

자세한 내용은 Azure Spring Apps에서 Application Insights Java In-Process 에이전트 사용을 참조하세요.

컨테이너

참고 항목

Spring Boot 네이티브 이미지 애플리케이션에서는 Application Insights Java 에이전트 대신 Spring Boot 네이티브 이미지 Java 애플리케이션 프로젝트의 Azure Monitor OpenTelemetry Distro/Application Insights를 사용합니다.

Docker 진입점

exec 양식을 사용하는 경우 "-jar" 매개 변수 앞의 매개 변수 목록에 매개 변수 -javaagent:"path/to/applicationinsights-agent-3.5.2.jar"을 추가합니다. 예를 들면 다음과 같습니다.

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

shell 형식을 사용하는 경우 JVM(Java Virtual Machine) 인수 -javaagent:"path/to/applicationinsights-agent-3.5.2.jar"-jar 앞 부분에 추가합니다. 예를 들면 다음과 같습니다.

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

Docker 파일

Dockerfile 예:

FROM ...

COPY target/*.jar app.jar

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

COPY agent/applicationinsights.json applicationinsights.json

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

이 예에서는 agent 폴더에서 applicationinsights-agent-3.5.2.jarapplicationinsights.json 파일을 복사합니다(컴퓨터의 모든 폴더를 선택할 수 있음). 이 두 파일은 Docker 컨테이너의 동일한 폴더에 있어야 합니다.

파트너 컨테이너 이미지

수정할 수 없는 파트너 컨테이너 이미지를 사용하는 경우 Application Insights Java 에이전트 jar를 외부에서 컨테이너에 탑재합니다. 컨테이너 JAVA_TOOL_OPTIONS=-javaagent:/path/to/applicationinsights-agent.jar에 대한 환경 변수를 설정합니다.

Spring Boot

자세한 내용은 Spring Boot와 함께 Azure Monitor Application Insights 사용을 참조하세요.

Java 애플리케이션 서버

Application Insights Java 에이전트 설정에 대한 자세한 내용은 Java용 Azure Monitor OpenTelemetry 사용을 참조하세요. 다음 섹션에서는 다른 애플리케이션 서버에서 -javaagent:... JVM 인수를 구성할 때 도움이 될 수 있는 세부 정보를 제공합니다.

Tomcat 8(Linux)

apt-get 또는 yum을 통해 설치된 Tomcat

apt-get 또는 yum을 통해 Tomcat을 설치한 경우 /etc/tomcat8/tomcat8.conf 파일이 있어야 합니다. 해당 파일 끝에 다음 줄을 추가합니다.

JAVA_OPTS="$JAVA_OPTS -javaagent:path/to/applicationinsights-agent-3.5.2.jar"

다운로드 및 압축 해제를 통해 설치된 Tomcat

https://tomcat.apache.org에서 다운로드 및 압축 해제를 통해 Tomcat을 설치한 경우 <tomcat>/bin/catalina.sh 파일이 있어야 합니다. 다음 내용이 포함된 <tomcat>/bin/setenv.sh라는 동일한 디렉터리에 새 파일을 만듭니다.

CATALINA_OPTS="$CATALINA_OPTS -javaagent:path/to/applicationinsights-agent-3.5.2.jar"

<tomcat>/bin/setenv.sh 파일이 이미 있는 경우 해당 파일을 수정하고 -javaagent:path/to/applicationinsights-agent-3.5.2.jarCATALINA_OPTS에 추가합니다.

Tomcat 8(Windows)

명령줄에서 Tomcat 실행

파일 <tomcat>/bin/catalina.bat를 찾습니다. 다음 내용이 포함된 <tomcat>/bin/setenv.bat라는 동일한 디렉터리에 새 파일을 만듭니다.

set CATALINA_OPTS=%CATALINA_OPTS% -javaagent:path/to/applicationinsights-agent-3.5.2.jar

따옴표는 필요하지는 않지만 이를 포함하려는 경우 적절한 배치는 다음과 같습니다.

set "CATALINA_OPTS=%CATALINA_OPTS% -javaagent:path/to/applicationinsights-agent-3.5.2.jar"

<tomcat>/bin/setenv.bat 파일이 이미 있는 경우 해당 파일을 수정하고 -javaagent:path/to/applicationinsights-agent-3.5.2.jarCATALINA_OPTS에 추가합니다.

Tomcat을 Windows 서비스로 실행

파일 <tomcat>/bin/tomcat8w.exe를 찾습니다. 해당 실행 파일을 실행하고 Java 탭 아래의 Java Options-javaagent:path/to/applicationinsights-agent-3.5.2.jar을 추가합니다.

JBoss Enterprise Application Platform 7

Red Hat JBoss EAP(Enterprise Application Platform) 7에서는 독립 실행형 서버 또는 도메인 서버를 설정할 수 있습니다.

독립 실행형 서버

파일 JBOSS_HOME/bin/standalone.conf(Linux) 또는 JBOSS_HOME/bin/standalone.conf.bat(Windows)의 기존 JAVA_OPTS 환경 변수에 -javaagent:path/to/applicationinsights-agent-3.5.2.jar을 추가합니다.

    JAVA_OPTS="-javaagent:path/to/applicationinsights-agent-3.5.2.jar -Xms1303m -Xmx1303m ..."
    ...

도메인 서버

JBOSS_HOME/domain/configuration/host.xml의 기존 jvm-options-javaagent:path/to/applicationinsights-agent-3.5.2.jar을 추가합니다.

...
<jvms>
    <jvm name="default">
        <heap size="64m" max-size="256m"/>
        <jvm-options>
            <option value="-server"/>
            <!--Add Java agent jar file here-->
            <option value="-javaagent:path/to/applicationinsights-agent-3.5.2.jar"/>
            <option value="-XX:MetaspaceSize=96m"/>
            <option value="-XX:MaxMetaspaceSize=256m"/>
        </jvm-options>
    </jvm>
</jvms>
...

단일 호스트에서 여러 관리 대상 서버를 실행하는 경우 각 server에 대해 system-propertiesapplicationinsights.agent.id를 추가해야 합니다.

...
<servers>
    <server name="server-one" group="main-server-group">
        <!--Edit system properties for server-one-->
        <system-properties> 
            <property name="applicationinsights.agent.id" value="..."/>
        </system-properties>
    </server>
    <server name="server-two" group="main-server-group">
        <socket-bindings port-offset="150"/>
        <!--Edit system properties for server-two-->
        <system-properties>
            <property name="applicationinsights.agent.id" value="..."/> 
        </system-properties>
    </server>
</servers>
...

지정된 applicationinsights.agent.id 값은 고유해야 합니다. 값을 사용하여 Application Insights 디렉터리 아래에 하위 디렉터리를 만듭니다. 각 JVM 프로세스에는 자체 로컬 Application Insights 구성 및 로컬 Application Insights 로그 파일이 필요합니다. 또한 중앙 수집기에 보고하는 경우 여러 관리 서버가 applicationinsights.properties 파일을 공유하므로 해당 공유 파일의 agent.id 설정을 재정의하려면 지정된 applicationinsights.agent.id가 필요합니다. 관리되는 서버별로 agent.rollup.id 설정을 재정의해야 하는 경우 applicationinsights.agent.rollup.id는 서버의 system-properties에 비슷한 방식으로 지정할 수 있습니다.

Jetty 9

이러한 줄을 start.ini에 추가합니다.

--exec
-javaagent:path/to/applicationinsights-agent-3.5.2.jar

Payara 5

glassfish/domains/domain1/config/domain.xml의 기존 jvm-options-javaagent:path/to/applicationinsights-agent-3.5.2.jar을 추가합니다.

...
<java-config ...>
    <!--Edit the JVM options here-->
    <jvm-options>
        -javaagent:path/to/applicationinsights-agent-3.5.2.jar>
    </jvm-options>
        ...
</java-config>
...

WebSphere 8

  1. 관리 콘솔을 엽니다.

  2. 서버>WebSphere 애플리케이션 서버>애플리케이션 서버로 이동합니다. 적절한 애플리케이션 서버를 선택하고 Java 및 프로세스 관리>프로세스 정의>Java Virtual Machine을 선택합니다.

  3. Generic JVM arguments에서 다음 JVM 인수를 추가합니다.

    -javaagent:path/to/applicationinsights-agent-3.5.2.jar
    
  4. 애플리케이션 서버를 저장하고 다시 시작합니다.

OpenLiberty 18

서버 디렉터리(예: <openliberty>/usr/servers/defaultServer)에 새 파일 jvm.options를 만들고 다음 줄을 추가합니다.

-javaagent:path/to/applicationinsights-agent-3.5.2.jar

기타

JVM 인수 추가 방법은 애플리케이션 서버 설명서를 참조하세요.