Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

Table of Contents

01. 사전조건

02. applicationinsights-agent 설정

02-01. Applicationinsights-agent-3.0.0를 다운로드 합니다.

02-02. Spring Boot Application에 'ApplicationInsights-agent' 폴더를 만들고 jar파일을 위치 시킵니다.

Code Block
languagejs
titleapplicationinsights.json
{
  "connectionString": "InstrumentationKey=23bb2ca3-8a38-4a3c-b5b5-f45f2ea33a7d;IngestionEndpoint=https://koreacentral-0.in.applicationinsights.azure.com/"
}
Code Block
languagexml
titleAI-Agent.xml
<?xml version="1.0" encoding="utf-8"?>
<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" />

            <!-- 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>

02-03. JVM환경변수로 javaagent를 설정합니다.

Info
  • VM options
    • -javaagent:C:\workspace\reactive-shorturl-webui\ApplicationInsights-agent\applicationinsights-agent-3.0.0.jar

02-04. Spring Boot Application을 실행하면, Java Agent관련 로그가 확인 됩니다.

Code Block
"C:\Program Files\Java\jdk-11.0.2\bin\java.exe" -javaagent:C:\workspace\reactive-shorturl-webui\ApplicationInsights-agent\applicationinsights-agent-3.0.0.jar -javaagent:C:\Users\sansae\AppData\Local\JetBrains\Toolbox\apps\IDEA-C\ch-0\202.8194.7\lib\idea_rt.jar=54632:C:\Users\sansae\AppData\Local\JetBrains\Toolbox\apps\IDEA-C\ch-0\202.8194.7\bin -Dfile.encoding=UTF-8 

~~~~~~~~~~~~~~~~~~~~~~~ 중략 ~~~~~~~~~~~~~~~~~~~~~~~ 

2021-01-04 12:20:41.147+09 INFO  c.m.applicationinsights.agent - ApplicationInsights Java Agent started successfully

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.7.RELEASE)

2021-01-02 12:20:44.929  INFO 6312 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 19ms. Found 0 Redis repository interfaces.
2021-01-02 12:20:47.585  WARN 6312 --- [           main] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2021-01-02 12:20:49.115  INFO 6312 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 8080
2021-01-02 12:20:49.130  INFO 6312 --- [           main] com.sansae.shorturl.ShorturlApplication  : Started ShorturlApplication in 7.332 seconds (JVM running for 18.768)

03. Application Insights 확인

03-01. Application map

03-02. Performance