Azure Cosmos DB for Apache Gremlin で高度な診断クエリを使用して問題をトラブルシューティングする

適用対象: NoSQL MongoDB Cassandra Gremlin

この記事では、Azure Diagnostics (レガシ) テーブルとリソース固有 (プレビュー) テーブルに送信される診断ログを使用して、Azure Cosmos DB アカウントに関する問題のトラブルシューティングに役立つ、より高度なクエリを作成する方法について説明します。

Azure Diagnostics テーブルの場合、すべてのデータが 1 つのテーブルに書き込まれます。 クエリを実行するカテゴリをユーザーが指定します。 要求のフルテキスト クエリを確認したい場合は、「Azure の診断設定を使用して Azure Cosmos DB データを監視する」で、この機能を有効にする方法を参照してください。

リソース固有テーブルの場合、データはリソースのカテゴリごとに個別のテーブルに書き込まれます。 次の理由から、このモードをお勧めします。

  • データの扱いがはるかに容易である。
  • スキーマが見つけやすい。
  • インジェストの待ち時間とクエリ時間の両方でパフォーマンスが向上する。

一般的なクエリ

一般的なクエリは、リソース固有のテーブルと Azure Diagnostics のテーブルに表示されます。

特定の時間枠内に要求またはクエリを使用する上位 N (10) 要求ユニット (RU)

CDBGremlinRequests
| project PIICommandText, ActivityId, DatabaseName , CollectionName
| join kind=inner topRequestsByRUcharge on ActivityId
| project DatabaseName , CollectionName , PIICommandText , RequestCharge, TimeGenerated
| order by RequestCharge desc
| take 10

特定の時間枠に調整された要求 (statusCode = 429)

CDBGremlinRequests
| project PIICommandText, ActivityId, DatabaseName , CollectionName
| join kind=inner throttledRequests on ActivityId
| project DatabaseName , CollectionName , PIICommandText , OperationName, TimeGenerated

応答の長さが長いクエリ (サーバー応答のペイロード サイズ)

CDBGremlinRequests
//specify collection and database
 //| where DatabaseName == "DB NAME" and CollectionName == "COLLECTIONNAME"
| join kind=inner operationsbyUserAgent on ActivityId
| summarize max(ResponseLength) by PIICommandText
| order by max_ResponseLength desc

物理パーティション別の RU 消費量 (レプリカ セット内のすべてのレプリカ)

CDBPartitionKeyRUConsumption
| where TimeGenerated >= now(-1d)
//specify collection and database
//| where DatabaseName == "DB NAME" and CollectionName == "COLLECTIONNAME"
// filter by operation type
//| where operationType_s == 'Create'
| summarize sum(todouble(RequestCharge)) by toint(PartitionKeyRangeId)
| render columnchart

論理パーティション別の RU 消費量 (レプリカ セット内のすべてのレプリカ)

CDBPartitionKeyRUConsumption
| where TimeGenerated >= now(-1d)
//specify collection and database
//| where DatabaseName == "DB NAME" and CollectionName == "COLLECTIONNAME"
// filter by operation type
//| where operationType_s == 'Create'
| summarize sum(todouble(RequestCharge)) by PartitionKey, PartitionKeyRangeId
| render columnchart  

次のステップ