Azure Monitor Application Insights에서 누락된 애플리케이션 원격 분석 문제 해결

이 문서는 PowerShell 또는 curl을 사용하여 연결 및 원격 분석 수집을 테스트하여 원격 분석이 누락되는 처리 파이프라인의 단계를 식별하는 데 도움이 됩니다.

원격 분석이 누락될 수 있는 단계

다음 그래픽은 수집 및 사용 중에 원격 분석이 누락될 수 있는 단계를 보여줍니다.

원격 분석이 처리 파이프라인에서 전달하는 단계입니다.

애플리케이션 원격 분석이 Azure Portal 표시되지 않으면 처리 파이프라인의 단계 간 오류가 원인일 수 있습니다.

  • Application Insights SDK 또는 에이전트가 잘못 구성되었으며 애플리케이션 원격 분석을 수집 엔드포인트로 보내지 않습니다.
  • SDK 또는 에이전트가 올바르게 구성되었지만 네트워크에서 수집 엔드포인트에 대한 호출을 차단합니다.
  • 수집 엔드포인트는 인바운드 원격 분석을 삭제하거나 제한합니다.
  • 수집 파이프라인은 서비스 상태로 인해 처리의 일부로 원격 분석을 삭제하거나 심각하게 느리게 합니다.
  • (일반적이지 않음) Log Analytics는 원격 분석 레코드를 저장할 때 서비스 상태 문제에 직면합니다.
  • (일반적이지 않음) Log Analytics에서 레코드를 쿼리할 때 의 api.applicationinsights.io 쿼리 API가 실패합니다.
  • Azure Portal 보려는 레코드를 끌어오거나 렌더링하지 못합니다.

샘플 원격 분석 레코드를 전송하여 단계 식별

구성 문제 또는 일시적인 문제는 Applications Insights 서비스 전체에서 발생할 수 있습니다. 데이터가 없거나 누락된 증상이 발생하는 처리 파이프라인 내의 단계를 식별하려면 PowerShell 또는 curl을 사용하여 샘플 원격 분석 레코드를 보냅니다. PowerShell 스크립트 또는 curl 명령의 경우 다음 섹션으로 이동합니다.

웹앱이 온-프레미스 서버 또는 Azure VM에서 실행되는 경우 서버 또는 VM에 연결하고 PowerShell을 사용하여 단일 원격 분석 레코드를 Applications Insights 서비스 instance 보냅니다. 원격 분석을 보내는 데 문제가 있는 웹앱이 Kudu에서 실행되는 경우 Azure Web Apps Kudu의 PowerShell 디버그 콘솔에서 다음 스크립트를 실행합니다.

$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest -Uri $url -Method POST -Body $availabilityData -UseBasicParsing

참고

  • cmdlet을 Invoke-WebRequest 실행하기 전에 cmdlet을 실행합니다 $ProgressPreference = "SilentlyContinue" .
  • 또는 -Debug을 사용할 -Verbose 수 없습니다. 대신 를 사용합니다 -UseBasicParsing.

PowerShell을 사용하여 샘플 원격 분석 레코드를 보낸 후 Azure Portal Application Insights 로그 탭으로 이동하여 도착하는 경우 검사. 샘플 원격 분석 레코드가 표시되면 처리 파이프라인의 상당 부분이 제거됩니다.

올바르게 저장되고 표시되는 샘플 원격 분석 레코드는 다음을 의미합니다.

  • 로컬 서버 또는 VM에는 올바른 IP 주소로 확인되는 DNS가 있습니다.
  • 네트워크는 차단 또는 삭제하지 않고 수집 엔드포인트에 샘플을 전달했습니다.
  • 수집 엔드포인트는 샘플 페이로드를 수락하고 수집 파이프라인을 통해 처리했습니다.
  • Log Analytics는 샘플 레코드를 올바르게 저장했습니다.
  • Azure Portal 로그 탭은 API(api.applicationinsights.io)를 쿼리하고 Azure Portal 샘플 레코드를 렌더링할 수 있습니다.

생성된 샘플 레코드가 Application Insights instance 도착하고 로그 리소스 메뉴를 사용하여 샘플 레코드를 쿼리할 수 있는 경우 Application Insights SDK 또는 에이전트 문제를 해결합니다. 그런 다음 SDK 또는 에이전트 버전에 적합한 SDK 로그, 자체 진단 로그 또는 프로파일러 추적 수집을 진행할 수 있습니다.

다음 섹션에서는 PowerShell 또는 curl을 사용하여 샘플 원격 분석 레코드를 보내는 방법에 대한 정보를 제공합니다.

가용성 테스트 결과를 보내는 PowerShell 스크립트

가용성 테스트 결과는 테스트하기에 이상적인 원격 분석 유형입니다. 그 이유는 수집 파이프라인이 가용성 테스트 결과를 샘플화하지 않았기 때문입니다. 요청 원격 분석 레코드를 보내는 경우 수집 샘플링을 사용하도록 설정하면 샘플링될 수 있습니다. 샘플 가용성 테스트 결과로 시작한 다음 필요에 따라 다른 원격 분석 유형을 시도합니다.

가용성 테스트 결과를 보내는 샘플 PowerShell 스크립트는 다음과 같습니다.

# Info: Provide either the connection string or ikey for your Application Insights resource
$ConnectionString = ""
$InstrumentationKey = ""
function ParseConnectionString {
param ([string]$ConnectionString)
  $Map = @{}
  foreach ($Part in $ConnectionString.Split(";")) {
     $KeyValue = $Part.Split("=")
     $Map.Add($KeyValue[0], $KeyValue[1])
  }
  return $Map
}
# If ikey is the only parameter supplied, we'll send telemetry to the global ingestion endpoint instead of regional endpoint found in connection strings
If (($InstrumentationKey) -and ("" -eq $ConnectionString)) {
$ConnectionString = "InstrumentationKey=$InstrumentationKey;IngestionEndpoint=https://dc.services.visualstudio.com/"
}
$map = ParseConnectionString($ConnectionString)
$url = $map["IngestionEndpoint"] + "v2/track"
$ikey = $map["InstrumentationKey"]
$lmUrl = $map["LiveEndpoint"]
$time = (Get-Date).ToUniversalTime().ToString("o")
$availabilityData = @"
{
  "data": {
        "baseData": {
            "ver": 2,
            "id": "SampleRunId",
            "name": "Microsoft Support Sample Webtest Result",
            "duration": "00.00:00:10",
            "success": true,
            "runLocation": "Region Name",
            "message": "Sample Webtest Result",
            "properties": {
                "Sample Property": "Sample Value"
                }
        },
        "baseType": "AvailabilityData"
  },
  "ver": 1,
  "name": "Microsoft.ApplicationInsights.Metric",
  "time": "$time",
  "sampleRate": 100,
  "iKey": "$ikey",
  "flags": 0
}
"@
# Uncomment one or more of the following lines to test client TLS/SSL protocols other than the machine default option
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::SSL3
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS11
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS12
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS13
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest -Uri $url -Method POST -Body $availabilityData -UseBasicParsing

이 스크립트는 Application Insights 구성 요소에 단일 가용성 테스트 결과를 제공하는 원시 REST 요청을 빌드합니다. 이 스크립트를 사용하는 경우 또는 $InstrumentationKey 매개 변수를 $ConnectionString 입력합니다.

  • 연결 문자열 매개 변수만 제공되면 원격 분석이 연결 문자열 지역 엔드포인트로 전송됩니다.
  • 계측 키(ikey) 매개 변수만 제공되면 원격 분석이 전역 수집 엔드포인트로 전송됩니다.
  • 연결 문자열 및 ikey 매개 변수가 모두 제공되면 스크립트는 연결 문자열 지역 엔드포인트로 원격 분석을 보냅니다.

참고

  • 애플리케이션에서 만든 연결을 테스트합니다. Azure Portal Application Insights를 사용하도록 설정하면 지역 엔드포인트가 인 연결 문자열을 사용할 수 있습니다https://<region>.in.applicationinsights.azure.com. SDK 구성에서 ikey만 제공하는 경우 전역 엔드포인트 https://dc.applicationinsights.azure.com인 를 사용합니다. 연결 문자열 또는 ikey를 제공하는 웹 애플리케이션 SDK 구성과 일치하는 스크립트 매개 변수를 채워야 합니다.
  • 2025년 3월 31일에 계측 키 수집에 대한 지원이 종료됩니다. 계측 키 수집은 계속 작동하지만 더 이상 기능에 대한 업데이트 또는 지원을 제공하지 않습니다. 새 기능을 활용하려면 연결 문자열로 전환합니다.

IaaS 또는 Azure 가상 머신 확장 집합 instance PowerShell ISE 환경에서 이 스크립트를 실행하는 것이 가장 쉽습니다. 스크립트를 복사하여 App Service Kudu 인터페이스 PowerShell 디버그 콘솔에 붙여넣은 다음 실행할 수도 있습니다.

스크립트가 실행되면 HTTP 200 응답을 찾고 응답 세부 정보를 검토합니다. 응답 JSON 페이로드의 일부로 다음과 같은 세부 정보가 필요합니다.

  • 개수는 itemsReceived 과 일치합니다 itemsAccepted.
  • 수집 엔드포인트는 하나의 원격 분석 레코드를 보냈고 하나의 원격 분석 레코드를 수락했습니다.

예제로 다음 스크린샷을 참조하세요.

받은 항목의 양과 수락된 항목을 보여 주는 코드입니다.

가용성 테스트 결과를 보내는 Curl 명령

Linux VM을 실행하는 경우 PowerShell 대신 curl을 사용하여 유사한 REST 요청을 보냅니다. 수집 엔드포인트 호스트 이름, iKey 값 및 time 값을 조정해야 합니다. Application Insights 수집 엔드포인트는 48시간보다 오래된 레코드를 허용하지 않습니다.

다음은 단일 가용성 테스트 결과를 보내는 샘플 curl 명령입니다.

  • Linux/MacOS용 Curl 명령:

    curl -H "Content-Type: application/json" -X POST -d '{"data":{"baseData":{"ver":2,"id":"SampleRunId","name":"MicrosoftSupportSampleWebtestResultUsingCurl","duration":"00.00:00:10","success":true,"runLocation":"RegionName","message":"SampleWebtestResult","properties":{"SampleProperty":"SampleValue"}},"baseType":"AvailabilityData"},"ver":1,"name":"Microsoft.ApplicationInsights.Metric","time":"2022-09-01T12:00:00.0000000Z","sampleRate":100,"iKey":"########-####-####-####-############","flags":0}' https://dc.applicationinsights.azure.com/v2.1/track
    
  • Windows용 Curl 명령:

    curl -H "Content-Type: application/json" -X POST -d {\"data\":{\"baseData\":{\"ver\":2,\"id\":\"SampleRunId\",\"name\":\"MicrosoftSupportSampleWebtestResultUsingCurl\",\"duration\":\"00.00:00:10\",\"success\":true,\"runLocation\":\"RegionName\",\"message\":\"SampleWebtestResult\",\"properties\":{\"SampleProperty\":\"SampleValue\"}},\"baseType\":\"AvailabilityData\"},\"ver\":1,\"name\":\"Microsoft.ApplicationInsights.Metric\",\"time\":\"2021-10-05T22:00:00.0000000Z\",\"sampleRate\":100,\"iKey\":\"########-####-####-####-############\",\"flags\":0} https://dc.applicationinsights.azure.com/v2/track
    

요청 원격 분석 레코드를 보내는 PowerShell 스크립트

누락된 요청 원격 분석 문제를 해결하려면 다음 PowerShell 스크립트를 사용하여 단일 요청 원격 분석 레코드 전송을 테스트합니다. 이 원격 분석 유형은 서버 쪽 수집 샘플링 구성에 취약합니다. 수집 샘플링이 꺼져 있는지 확인하여 테스트 레코드가 올바르게 저장되었는지 확인합니다.

# Info: Provide either the connection string or ikey for your Application Insights resource
$ConnectionString = ""
$InstrumentationKey = ""
function ParseConnectionString {
param ([string]$ConnectionString)
  $Map = @{}
  foreach ($Part in $ConnectionString.Split(";")) {
     $KeyValue = $Part.Split("=")
     $Map.Add($KeyValue[0], $KeyValue[1])
  }
  return $Map
}
# If ikey is the only parameter supplied, we'll send telemetry to the global ingestion endpoint instead of regional endpoint found in connection strings
If (($InstrumentationKey) -and ("" -eq $ConnectionString)) {
$ConnectionString = "InstrumentationKey=$InstrumentationKey;IngestionEndpoint=https://dc.services.visualstudio.com/"
}
$map = ParseConnectionString($ConnectionString)
$url = $map["IngestionEndpoint"] + "v2/track"
$ikey = $map["InstrumentationKey"]
$lmUrl = $map["LiveEndpoint"]
$time = (Get-Date).ToUniversalTime().ToString("o")
$requestData = @"
{
   "data": {
      "baseType": "RequestData",
      "baseData": {
        "ver": 2,
        "id": "22093920382029384",
        "name": "GET /msftsupport/requestdata/",
        "starttime": "$time",
        "duration": "00:00:01.0000000",
        "success": true,
        "responseCode": "200",
        "url": "https://localhost:8080/requestData/sampleurl",
        "httpMethod": "GET"
       }
   },
   "ver": 1,
   "iKey": "$ikey",
   "name": "Microsoft.ApplicationInsights.Request",
   "time": "$time",
   "sampleRate": 100,
   "flags": 0
}
"@
# Uncomment one or more of the following lines to test client TLS/SSL protocols other than the machine default option
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::SSL3
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS11
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS12
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS13
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest -Uri $url -Method POST -Body $requestData -UseBasicParsing

SSL 또는 TLS 구성 문제 해결

위의 스크립트가 실패하면 SSL 또는 TLS 구성 문제를 해결합니다. 대부분의 수집 엔드포인트는 클라이언트가 TLS 1.2 및 특정 암호 그룹을 사용해야 합니다. 이 경우 PowerShell이 SSL 또는 TLS 프로토콜에서 클라이언트로 참여하는 방식을 조정합니다. 클라이언트 VM과 수집 엔드포인트 간의 연결의 일부로 보안 채널을 진단해야 하는 경우 다음 코드 조각을 포함합니다.

  • 옵션 1: 수집 엔드포인트에 연결하기 위해 PowerShell에서 사용하는 SSL 또는 TLS 프로토콜을 제어합니다.

    문자를 제거하여 # 다음 줄의 주석 처리를 제거하고 PowerShell 스크립트의 Invoke-WebRequest cmdlet 앞에 추가하여 테스트 REST 요청에 사용되는 프로토콜을 제어합니다.

    # Uncomment one or more of these lines to test TLS/SSL protocols other than the machine default option
    # [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::SSL3
    # [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS
    # [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS11
    # [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS12
    # [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS13
    
  • 옵션 2: SSL 인증서 유효성 검사 문제를 무시합니다.

    SSL 인증서 오프로드에 참여하는 방화벽 또는 프록시 서버가 있는 경우 cmdlet 바로 앞에 Invoke-WebRequest 다음 코드 조각을 추가하여 SSL 인증서 문제를 무시합니다.

    # Ignore mismatched SSL certificate
    add-type @"
        using System.Net;
        using System.Security.Cryptography.X509Certificates;
        public class TrustAllCertsPolicy : ICertificatePolicy {
            public bool CheckValidationResult(
                ServicePoint srvPoint, X509Certificate certificate,
                WebRequest request, int certificateProblem) {
                return true;
            }
        }
    "@
    [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
    

애플리케이션이 기본값이 시스템 또는 서버 기본 TLS 설정인 경우 Windows 컴퓨터의 레지스트리 내에서 해당 기본 설정을 변경합니다. 자세한 내용은 TLS(전송 계층 보안) 레지스트리 설정을 참조하세요.

.NET 애플리케이션에서 사용하는 기본 TLS/SSL 프로토콜을 변경해야 하는 경우 .NET Framework TLS(전송 계층 보안) 모범 사례의 지침을 따릅니다.

Application Insights SDK 또는 에이전트 설정 또는 구성 문제 해결

PowerShell 또는 curl을 사용하여 애플리케이션의 호스트 컴퓨터에서 원격 분석을 보내는 데 성공하면 Application Insights SDK 또는 에이전트의 설정 또는 구성 문제로 인해 원격 분석이 누락된 것일 수 있습니다. 애플리케이션 호스트 및 프로그래밍 언어에 대해 Application Insights 모니터링을 사용하도록 설정하여 모든 구성 또는 코드가 적절한 지침 및 예제를 따르는지 확인합니다.

PowerShell 또는 curl을 사용하여 수행한 테스트가 수집 엔드포인트에 원격 분석을 보내지 못하는 경우 문제에 기여할 수 있는 몇 가지 일반적인 클라이언트 쪽 관련 문제를 확인합니다.

  • 네트워크의 DNS가 수집 엔드포인트를 올바른 IP 주소로 resolve 못합니다.
  • 애플리케이션 서버에서 수집 엔드포인트로의 TCP 연결은 방화벽 또는 게이트웨이 디바이스에 의해 차단될 수 있습니다.
  • SDK가 연결하는 수집 엔드포인트에는 TLS 1.2가 필요할 수 있지만 애플리케이션은 기본적으로 TLS 1.0 또는 TLS 1.1을 사용할 수 있습니다.
  • 프라이빗 네트워크에 영향을 미치는 Azure Monitor Private Link 둘 이상 있을 수 있으며, 이는 수집 엔드포인트를 잘못된 개인 IP 주소로 resolve DNS 항목을 덮어쓸 수 있습니다.

도움을 요청하십시오.

질문이 있거나 도움이 필요한 경우 지원 요청을 생성하거나Azure 커뮤니티 지원에 문의하세요. Azure 피드백 커뮤니티에 제품 피드백을 제출할 수도 있습니다.