事件
針對 Azure Cosmos DB for NoSQL 的進階診斷查詢問題進行疑難排解
適用於: NoSQL
在本文中,我們將探討如何使用傳送至 Azure 診斷 (舊版) 和資源專用 (預覽) 資料表的診斷記錄,撰寫更進階的查詢,協助針對 Azure Cosmos DB 帳戶的問題進行疑難排解。
Azure 診斷資料表的所有資料皆會寫入單一資料表中。 使用者指定要查詢的類別。 若要檢視要求的全文檢索查詢,請參閱使用 Azure 中的診斷設定來監視 Azure Cosmos DB 資料,了解如何啟用這項功能。
資源專屬資料表的資料會寫入該資源各類別的個別資料表。 建議採用此模式,因為:
- 使用資料時更方便。
- 可更深入探索結構描述。
- 同時改善擷取延遲及查詢時間兩者的效能。
資源專屬及 Azure 診斷資料表會顯示常用查詢。
Kusto
let topRequestsByRUcharge = CDBDataPlaneRequests
| where TimeGenerated > ago(24h)
| project RequestCharge , TimeGenerated, ActivityId;
CDBQueryRuntimeStatistics
| project QueryText, ActivityId, DatabaseName , CollectionName
| join kind=inner topRequestsByRUcharge on ActivityId
| project DatabaseName , CollectionName , QueryText , RequestCharge, TimeGenerated
| order by RequestCharge desc
| take 10
Kusto
let throttledRequests = CDBDataPlaneRequests
| where StatusCode == "429"
| project OperationName , TimeGenerated, ActivityId;
CDBQueryRuntimeStatistics
| project QueryText, ActivityId, DatabaseName , CollectionName
| join kind=inner throttledRequests on ActivityId
| project DatabaseName , CollectionName , QueryText , OperationName, TimeGenerated
Kusto
let operationsbyUserAgent = CDBDataPlaneRequests
| project OperationName, DurationMs, RequestCharge, ResponseLength, ActivityId;
CDBQueryRuntimeStatistics
//specify collection and database
//| where DatabaseName == "DBNAME" and CollectionName == "COLLECTIONNAME"
| join kind=inner operationsbyUserAgent on ActivityId
| summarize max(ResponseLength) by QueryText
| order by max_ResponseLength desc
Kusto
CDBPartitionKeyRUConsumption
| where TimeGenerated >= now(-1d)
//specify collection and database
//| where DatabaseName == "DBNAME" and CollectionName == "COLLECTIONNAME"
// filter by operation type
//| where operationType_s == 'Create'
| summarize sum(todouble(RequestCharge)) by toint(PartitionKeyRangeId)
| render columnchart
Kusto
CDBPartitionKeyRUConsumption
| where TimeGenerated >= now(-1d)
//specify collection and database
//| where DatabaseName == "DBNAME" and CollectionName == "COLLECTIONNAME"
// filter by operation type
//| where operationType_s == 'Create'
| summarize sum(todouble(RequestCharge)) by PartitionKey, PartitionKeyRangeId
| render columnchart
- 如需有關如何為 Azure Cosmos DB 建立診斷設定的詳細資訊,請參閱建立診斷設定。
- 如需有關如何使用 Azure 入口網站、Azure CLI 或 PowerShell 建立診斷設定的詳細資訊,請參閱建立診斷設定以收集 Azure 中的平台記錄和計量。
其他資源
訓練
模組
在 Azure Cosmos DB for NoSQL 中監視回應和事件 - Training
我們將了解如何使用 Azure Cosmos DB 要求所傳回的一組豐富 REST 回應碼,以便協助您分析潛在問題。
認證
Microsoft Certified: Azure Cosmos DB Developer Specialty - Certifications
透過 Microsoft Azure Cosmos DB 在 SQL API 和 SDK 中撰寫有效率的查詢、建立索引編製原則、管理及佈建資源。