Share via


빠른 시작 - 애플리케이션 엔드투엔드 모니터링

참고 항목

Azure Spring Apps는 Azure Spring Cloud 서비스의 새 이름입니다. 서비스에 새 이름이 지정되었지만, 자산을 업데이트하는 동안 스크린샷, 비디오, 다이어그램과 같은 일부 위치에서는 당분간 이전 이름이 표시됩니다.

이 문서의 적용 대상:❌ 기본/표준 ✔️ 엔터프라이즈

이 빠른 시작에서는 Application Insights 및 Log Analytics를 사용하여 Azure Spring Apps 엔터프라이즈 플랜을 실행하는 앱을 모니터링하는 방법을 보여줍니다.

참고 항목

App Insights, Log Analytics, New Relic, Dynatrace, AppDynamics, Elastic 또는 Splunk를 비롯한 원하는 도구와 플랫폼을 사용하여 Spring 워크로드 엔드투엔드를 모니터링할 수 있습니다. 자세한 내용은 이 문서의 뒷부분에 있는 다른 모니터링 도구 사용을 참조하세요.

필수 조건

애플리케이션 업데이트

Application Insights 연결 문자열을 두문 서비스(ASP.NET core) 및 카트 서비스(python) 애플리케이션에 수동으로 제공해야 합니다. 다음 지침에서는 이 연결 문자열을 제공하고 Application Insights의 샘플링 속도를 높이는 방법을 설명합니다.

참고 항목

현재 Java 및 NodeJS 애플리케이션용 빌드팩만 Application Insights 계측을 지원합니다.

  1. 다음 명령을 사용하여 리소스 이름을 저장할 변수를 만듭니다. 자리 표시자를 사용자의 값으로 바꿔야 합니다. Azure Spring Apps 서비스 인스턴스의 이름은 4자에서 32자 사이여야 하며 소문자, 숫자 및 하이픈만 포함할 수 있습니다. 서비스 이름의 첫 글자는 문자여야 하며 마지막 문자는 문자 또는 숫자여야 합니다.

    export RESOURCE_GROUP="<resource-group-name>"
    export APP_INSIGHTS_NAME="<app-insights-name>"
    export KEY_VAULT_NAME="<key-vault-name>"
    export AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME="<Azure-Spring-Apps-service-instance-name>"
    

    참고 항목

    기본적으로 APP_INSIGHTS_NAME AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME 동일합니다.

  2. 다음 명령을 사용하여 Application Insights 연결 문자열을 검색하고 Key Vault에서 설정합니다.

    export CONNECTION_STRING=$(az monitor app-insights component show \
        --resource-group ${RESOURCE_GROUP} \
        --app ${APP_INSIGHTS_NAME} \
        --query "connectionString" \
        --output tsv)
    
    az keyvault secret set \
        --vault-name ${KEY_VAULT_NAME} \
        --name "ApplicationInsights--ConnectionString" \
        --value ${CONNECTION_STRING}
    
  3. 다음 명령을 사용하여 Application Insights 바인딩의 샘플링 속도를 업데이트한 후 사용 가능한 데이터의 양을 늘립니다.

    az spring build-service builder buildpack-binding set \
        --resource-group ${RESOURCE_GROUP} \
        --service ${AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME} \
        --builder-name default \
        --name default \
        --type ApplicationInsights \
        --properties sampling-rate=100 connection_string=${CONNECTION_STRING}
    
  4. 다음 명령을 사용하여 애플리케이션을 다시 시작한 후 구성을 다시 로드합니다.

    az spring app restart \
        --resource-group ${RESOURCE_GROUP} \
        --service ${AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME} \
        --name cart-service
    
    az spring app restart \
        --resource-group ${RESOURCE_GROUP} \
        --service ${AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME} \
        --name order-service
    
    az spring app restart \
        --resource-group ${RESOURCE_GROUP} \
        --service ${AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME} \
        --name catalog-service
    
    az spring app restart \
        --resource-group ${RESOURCE_GROUP} \
        --service ${AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME} \
        --name frontend
    
    az spring app restart \
        --resource-group ${RESOURCE_GROUP} \
        --service ${AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME} \
        --name payment-service
    
  5. Single Sign-On을 구성한 경우 다음 명령을 사용하여 애플리케이션을 다시 시작하여 ID 서비스 앱 구성을 다시 로드합니다.

    az spring app restart \
        --resource-group ${RESOURCE_GROUP} \
        --service ${AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME} \
        --name identity-service
    

    Java 및 NodeJS 애플리케이션의 경우 다시 시작하면 새 샘플링 속도를 적용할 수 있습니다. Java가 아닌 애플리케이션의 경우 다시 시작하면 Key Vault에서 새로 추가된 계측 키에 액세스할 수 있습니다.

로그 보기

앱 인스턴스당 실시간 로그의 로그 스트리밍 또는 고급 쿼리 기능이 있는 집계 로그의 Log Analytics로 Azure Spring Apps의 로그를 볼 수 있는 두 가지 방법이 있습니다.

로그 스트리밍 사용

애플리케이션을 통해 이동하고, 카탈로그를 보고, 주문을 하여 애플리케이션에서 트래픽을 생성합니다. 취소될 때까지 다음 명령을 사용하여 트래픽을 지속적으로 생성합니다.

export GATEWAY_URL=$(az spring gateway show \
    --resource-group ${RESOURCE_GROUP} \
    --service ${AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME} \
    --query "properties.url" \
    --output tsv)

export GATEWAY_URL=https://${GATEWAY_URL} 

cd azure-spring-apps-enterprise/load-test/traffic-generator
./gradlew gatlingRun-com.vmware.acme.simulation.GuestSimulation.java

다음 명령을 사용하여 카탈로그 서비스 애플리케이션에서 최근 애플리케이션 콘솔 로그 100줄을 가져옵니다.

az spring app logs \
    --resource-group ${RESOURCE_GROUP} \
    --name catalog-service \
    --service ${AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME} \
    --lines 100

--follow 옵션을 추가하면 앱에서 실시간 로그 스트리밍을 가져올 수 있습니다. 다음 명령을 사용하여 카탈로그 서비스 애플리케이션에 대한 로그 스트리밍을 시도합니다.

az spring app logs \
    --resource-group ${RESOURCE_GROUP} \
    --name catalog-service \
    --service ${AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME} \
    --follow

az spring app logs --help를 사용하여 더 많은 매개 변수 및 로그 스트림 기능을 탐색할 수 있습니다.

Log Analytics 사용

Azure Portal로 이동하여 만든 Log Analytics 인스턴스를 엽니다. Azure Spring Apps 서비스 인스턴스를 만든 동일한 리소스 그룹에서 Log Analytics 인스턴스를 찾을 수 있습니다.

Log Analytics 페이지에서 로그 창을 선택하고 Azure Spring Apps에 대해 다음 샘플 쿼리를 실행합니다.

다음 Kusto 쿼리를 입력하고 실행하여 애플리케이션 로그를 확인합니다.

AppPlatformLogsforSpring
| where TimeGenerated > ago(24h)
| limit 500
| sort by TimeGenerated
| project TimeGenerated, AppName, Log

이 쿼리는 다음 스크린샷에 표시된 것과 유사한 결과를 생성합니다.

Screenshot of Azure portal showing example output from all application logs query.

다음 Kusto 쿼리를 입력하고 실행하여 catalog-service 애플리케이션 로그를 확인합니다.

AppPlatformLogsforSpring
| where AppName has "catalog-service"
| limit 500
| sort by TimeGenerated
| project TimeGenerated, AppName, Log

이 쿼리는 다음 스크린샷에 표시된 것과 유사한 결과를 생성합니다.

Screenshot of Azure portal showing example output from Catalog Service application logs.

다음 Kusto 쿼리를 입력하고 실행하여 각 앱에서 throw된 오류 및 예외를 확인합니다.

AppPlatformLogsforSpring
| where Log contains "error" or Log contains "exception"
| extend FullAppName = strcat(ServiceName, "/", AppName)
| summarize count_per_app = count() by FullAppName, ServiceName, AppName, _ResourceId
| sort by count_per_app desc
| render piechart

이 쿼리는 다음 스크린샷에 표시된 것과 유사한 결과를 생성합니다.

Screenshot of Azure portal showing example output from the Ingress Logs.

다음 Kusto 쿼리를 입력하고 실행하여 Azure Spring Apps에 대한 인바운드 호출의 모든 항목을 확인합니다.

AppPlatformIngressLogs
| project TimeGenerated, RemoteAddr, Host, Request, Status, BodyBytesSent, RequestTime, ReqId, RequestHeaders
| sort by TimeGenerated

다음 Kusto 쿼리를 입력하고 실행하여 Azure Spring Apps에서 관리하는 관리형 Spring Cloud Config Gateway의 모든 로그를 확인합니다.

AppPlatformSystemLogs
| where LogType contains "SpringCloudGateway"
| project TimeGenerated,Log

이 쿼리는 다음 스크린샷에 표시된 것과 유사한 결과를 생성합니다.

Screenshot of Azure portal showing example output from the Spring Cloud Gateway Logs.

다음 Kusto 쿼리를 입력하고 실행하여 Azure Spring Apps에서 관리하는 관리형 Spring Cloud Service Registry의 모든 로그를 확인합니다.

AppPlatformSystemLogs
| where LogType contains "ServiceRegistry"
| project TimeGenerated, Log

이 쿼리는 다음 스크린샷에 표시된 것과 유사한 결과를 생성합니다.

Screenshot of Azure portal showing example output from service registry logs.

추적 사용

Azure Portal에서 Azure Spring Apps에서 만든 Application Insights 인스턴스를 열고 Spring Boot 애플리케이션의 모니터링을 시작합니다. Azure Spring Apps 서비스 인스턴스를 만든 동일한 리소스 그룹에서 Application Insights 인스턴스를 찾을 수 있습니다.

다음 스크린샷과 유사한 애플리케이션 맵 창으로 이동합니다.

Screenshot of Azure portal showing the Application Map of Azure Application Insights.

다음 스크린샷과 유사한 성능 창으로 이동합니다.

Screenshot of Azure portal showing the Performance pane of Azure Application Insights.

성능/종속성 창으로 이동합니다. 여기에서 다음 스크린샷에 표시된 것과 유사한 종속성, 특히 SQL 호출에 대한 성능 수치를 볼 수 있습니다.

Screenshot of Azure portal showing the Dependencies section of the Performance pane of Azure Application Insights.

성능/역할 창으로 이동합니다. 여기에서 다음 스크린샷에 표시된 것과 유사한 개별 인스턴스 또는 역할에 대한 성능 메트릭을 볼 수 있습니다.

Screenshot of Azure portal showing the Roles section of the Performance pane of Azure Application Insights.

SQL 호출을 선택하여 다음 스크린샷에 표시된 것과 유사한 컨텍스트에서 엔드투엔드 트랜잭션을 확인합니다.

Screenshot of Azure portal showing the end-to-end transaction of an S Q L call.

오류/예외 창으로 이동합니다. 여기에서 다음 스크린샷에 표시된 것과 유사한 예외 컬렉션을 볼 수 있습니다.

Screenshot of Azure portal showing application failures graphed.

메트릭 보기

메트릭 창으로 이동합니다. 여기에서 Spring Boot 앱, Spring Cloud 모듈, 종속성에서 제공하는 메트릭을 볼 수 있습니다. 다음 스크린샷의 차트는 http_server_requests사용된 힙 메모리를 보여 줍니다.

Screenshot of Azure portal showing metrics over time graph.

Spring Boot는 JVM, CPU, Tomcat, Logback 등 많은 핵심 메트릭을 등록합니다. Spring Boot 자동 구성은 Spring MVC가 처리하는 요청을 계측할 수 있도록 합니다. REST 컨트롤러 ProductController, PaymentController, @Timed는 모두 클래스 수준에서 Micrometer 주석에 의해 계측되었습니다.

acme-catalog 애플리케이션에는 다음과 같은 사용자 지정 메트릭이 활성화되어 있습니다. @Timed: store.products

acem-payment 애플리케이션에는 다음과 같은 사용자 지정 메트릭이 활성화되어 있습니다. @Timed: store.payment

다음 스크린샷과 같이 메트릭 창에서 이러한 사용자 지정 메트릭을 볼 수 있습니다.

Screenshot showing custom metrics instrumented by Micrometer.

라이브 메트릭 창으로 이동합니다. 다음 스크린샷과 같이 화면에서 대기 시간이 < 1초로 짧은 라이브 메트릭을 볼 수 있습니다.

Screenshot showing the live metrics of all applications.

다른 모니터링 도구 사용

또한 Azure Spring Apps 엔터프라이즈 플랜은 다음 도구를 포함하여 다른 도구로 메트릭 내보내기를 지원합니다.

  • AppDynamics
  • ApacheSkyWalking
  • Dynatrace
  • ElasticAPM
  • NewRelic

다음 명령을 사용하여 Tanzu Build Service의 작성기에서 더 많은 바인딩을 추가할 수 있습니다.

az spring build-service builder buildpack-binding create \
    --resource-group <resource-group-name> \
    --service <Azure-Spring-Apps-service-instance-name> \
    --builder-name <builder-name> \
    --name <binding-name> \
    --type <ApplicationInsights|AppDynamics|ApacheSkyWalking|Dynatrace|ElasticAPM|NewRelic> \
    --properties <connection-properties>
    --secrets <secret-properties>

리소스 정리

후속 빠른 시작 및 자습서를 계속 사용하려는 경우 이러한 리소스를 그대로 유지할 수 있습니다. 더 이상 필요 없으면 리소스 그룹을 삭제합니다. 그러면 리소스 그룹의 리소스가 삭제됩니다. Azure CLI를 사용하여 리소스 그룹을 삭제하려면 다음 명령을 사용합니다.

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
az group delete --name $resourceGroupName &&
echo "Press [ENTER] to continue ..."

다음 단계

다음 중 원하는 빠른 시작을 계속 진행합니다.