진단 쿼리 관련 문제 해결
적용 대상: NoSQL MongoDB Cassandra Gremlin 테이블
이 문서에서는 AzureDiagnostics(레거시) 및 리소스 관련(미리 보기) 테이블로 전송된 진단 로그를 사용하여 Azure Cosmos DB 계정 관련 문제 해결에 도움이 되는 간단한 쿼리를 작성하는 방법을 설명합니다.
Azure Diagnostics 테이블의 경우 모든 데이터가 하나의 단일 테이블에 기록되며 사용자는 쿼리할 범주를 지정해야 합니다.
리소스별 테이블의 경우 데이터는 리소스의 각 범주에 대한 개별 테이블에 기록됩니다(테이블 API에는 사용할 수 없음). 데이터를 훨씬 쉽게 다룰 수 있고 스키마를 더 정확하게 검색할 수 있으며 수집 대기 시간과 쿼리 시간 모두에서 성능이 향상되므로 이 모드를 사용하는 것이 좋습니다.
일반 쿼리
다음은 일반적인 문제 해결 쿼리 목록입니다.
실행하는 데 3밀리초 넘게 걸리는 작업 쿼리
지속 시간이 3밀리초보다 긴 작업을 찾습니다.
AzureDiagnostics
| where toint(duration_s) > 3 and ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
| summarize count() by clientIpAddress_s, TimeGenerated
작업을 실행하는 사용자 에이전트에 대한 쿼리
각 작업과 연결된 사용자 에이전트를 찾습니다.
AzureDiagnostics
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
| summarize count() by OperationName, userAgent_s
장기 실행 작업에 대한 쿼리
런타임을 5초 간격으로 범주화하여 오랫동안 실행된 작업을 찾습니다.
AzureDiagnostics
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
| project TimeGenerated , duration_s
| summarize count() by bin(TimeGenerated, 5s)
| render timechart
데이터베이스 계정의 상위 3개 파티션 간의 기울이기를 평가하기 위해 파티션 키 통계를 구합니다.
실제 파티션에 대한 공통 통계를 구하여 기울이기를 측정합니다.
AzureDiagnostics
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="PartitionKeyStatistics"
| project SubscriptionId, regionName_s, databaseName_s, collectionName_s, partitionKey_s, sizeKb_d, ResourceId
비용이 많이 드는 쿼리에 대한 요청 요금 구하기
가장 큰 쿼리에 대한 요청 요금(RU 단위)을 측정합니다.
AzureDiagnostics
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" and todouble(requestCharge_s) > 10.0
| project activityId_g, requestCharge_s
| join kind= inner (
AzureDiagnostics
| where ResourceProvider =="MICROSOFT.DOCUMENTDB" and Category == "QueryRuntimeStatistics"
| project activityId_g, querytext_s
) on $left.activityId_g == $right.activityId_g
| order by requestCharge_s desc
| limit 100
가장 많은 RU/s를 사용하는 작업 찾기
작업이 사용하는 RU/s의 양을 기준으로 작업을 정렬합니다.
AzureDiagnostics
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
| where TimeGenerated >= ago(2h)
| summarize max(responseLength_s), max(requestLength_s), max(requestCharge_s), count = count() by OperationName, requestResourceType_s, userAgent_s, collectionRid_s, bin(TimeGenerated, 1h)
100RU/s를 초과하여 사용하는 모든 쿼리 가져오기
기준 금액보다 더 많은 RU/s를 사용하는 쿼리를 찾습니다.
이 쿼리는 DataPlaneRequests
및 QueryRunTimeStatistics
의 데이터와 조인됩니다.
AzureDiagnostics
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" and todouble(requestCharge_s) > 100.0
| project activityId_g, requestCharge_s
| join kind= inner (
AzureDiagnostics
| where ResourceProvider =="MICROSOFT.DOCUMENTDB" and Category == "QueryRuntimeStatistics"
| project activityId_g, querytext_s
) on $left.activityId_g == $right.activityId_g
| order by requestCharge_s desc
| limit 100
요청 요금 및 쿼리 실행 시간 가져오기
특정 쿼리에 대한 요청 요금 및 지속 시간 모두에 대한 통계를 가져옵니다.
AzureDiagnostics
| where TimeGenerated >= ago(24hr)
| where Category == "QueryRuntimeStatistics"
| join (
AzureDiagnostics
| where TimeGenerated >= ago(24hr)
| where Category == "DataPlaneRequests"
) on $left.activityId_g == $right.activityId_g
| project databasename_s, collectionname_s, OperationName1 , querytext_s,requestCharge_s1, duration_s1, bin(TimeGenerated, 1min)
다양한 작업에 대한 배포 가져오기
리소스 배포를 기준으로 작업을 그룹화합니다.
AzureDiagnostics
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
| where TimeGenerated >= ago(2h)
| summarize count = count() by OperationName, requestResourceType_s, bin(TimeGenerated, 1h)
파티션이 사용한 최대 처리량 가져오기
실제 파티션의 최대 처리량을 가져옵니다.
AzureDiagnostics
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
| where TimeGenerated >= ago(2h)
| summarize max(requestCharge_s) by bin(TimeGenerated, 1h), partitionId_g
초당 파티션 키 RU/s 사용량에 대한 정보 가져오기
파티션 키별 초당 RU/s 사용량을 측정합니다.
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.DOCUMENTDB" and Category == "PartitionKeyRUConsumption"
| summarize total = sum(todouble(requestCharge_s)) by databaseName_s, collectionName_s, partitionKey_s, TimeGenerated
| order by TimeGenerated asc
특정 파티션 키에 대한 요청 요금 가져오기
파티션 키당 요청 요금을 측정합니다.
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.DOCUMENTDB" and Category == "PartitionKeyRUConsumption"
| where parse_json(partitionKey_s)[0] == "2"
특정 기간에 RU/s를 가장 많이 사용한 상위 파티션 키 가져오기
시간 범위 내의 요청 단위 사용량을 기준으로 파티션 키를 정렬합니다.
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.DOCUMENTDB" and Category == "PartitionKeyRUConsumption"
| where TimeGenerated >= datetime("11/26/2019, 11:20:00.000 PM") and TimeGenerated <= datetime("11/26/2019, 11:30:00.000 PM")
| summarize total = sum(todouble(requestCharge_s)) by databaseName_s, collectionName_s, partitionKey_s
| order by total desc
스토리지 크기가 8GB보다 큰 파티션 키에 대한 로그 가져오기
파티션 키당 스토리지 크기로 필터링된 파티션 키에 대한 로그를 찾습니다.
AzureDiagnostics
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="PartitionKeyStatistics"
| where todouble(sizeKb_d) > 800000
작업, 요청 요금 또는 응답 길이에 대한 P99 또는 P50 대기 시간 가져오기
작업 대기 시간, RU/s 사용량 및 응답 길이에 대한 성능을 측정합니다.
AzureDiagnostics
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
| where TimeGenerated >= ago(2d)
| summarize percentile(todouble(responseLength_s), 50), percentile(todouble(responseLength_s), 99), max(responseLength_s), percentile(todouble(requestCharge_s), 50), percentile(todouble(requestCharge_s), 99), max(requestCharge_s), percentile(todouble(duration_s), 50), percentile(todouble(duration_s), 99), max(duration_s), count() by OperationName, requestResourceType_s, userAgent_s, collectionRid_s, bin(TimeGenerated, 1h)
컨트롤 플레인 로그 가져오기
ControlPlaneRequests
를 사용하여 긴 컨트롤 플레인을 가져옵니다.
팁
키 기반 메타데이터 쓰기 액세스 사용 안 함에 설명된 플래그를 켜고, Azure PowerShell, Azure CLI 또는 Azure Resource Manager를 사용하여 작업을 실행해야 합니다.
AzureDiagnostics
| where Category =="ControlPlaneRequests"
| summarize by OperationName
다음 단계
- Azure Cosmos DB용 진단 설정을 만드는 방법에 대한 자세한 내용은 진단 설정 만들기를 참조하세요.
- Azure Portal, CLI 또는 PowerShell을 사용하여 진단 설정을 만드는 방법에 대한 자세한 정보는 Azure에서 플랫폼 로그 및 메트릭을 수집하는 진단 설정 만들기를 참조하세요.