Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
APPLIES TO:
NoSQL
MongoDB
Cassandra
Gremlin
In this article, we'll cover how to write more advanced queries to help troubleshoot issues with your Azure Cosmos DB account by using diagnostics logs sent to Azure Diagnostics (legacy) and resource-specific (preview) tables.
For Azure Diagnostics tables, all data is written into one single table. Users specify which category they want to query. If you want to view the full-text query of your request, see Monitor Azure Cosmos DB data by using diagnostic settings in Azure to learn how to enable this feature.
For resource-specific tables, data is written into individual tables for each category of the resource. We recommend this mode because it:
- Makes it much easier to work with the data.
- Provides better discoverability of the schemas.
- Improves performance across both ingestion latency and query times.
Common queries are shown in the resource-specific and Azure Diagnostics tables.
//Enable full-text query to view entire query text
CDBMongoRequests
| where TimeGenerated > ago(24h)
| project PIICommandText, ActivityId, DatabaseName , CollectionName, RequestCharge
| order by RequestCharge desc
| take 10
CDBMongoRequests
| where TimeGenerated > ago(24h)
| where ErrorCode == "429" or ErrorCode == "16500"
| project DatabaseName, CollectionName, PIICommandText, OperationName, TimeGenerated
CDBMongoRequests
| where TimeGenerated > ago(24h)
| where ErrorCode == "50"
| project DatabaseName, CollectionName, PIICommandText, OperationName, TimeGenerated
CDBMongoRequests
//specify collection and database
//| where DatabaseName == "DB NAME" and CollectionName == "COLLECTIONNAME"
| summarize max(ResponseLength) by PIICommandText, RequestCharge, DurationMs, OperationName, TimeGenerated
| order by max_ResponseLength desc
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
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
- For more information on how to create diagnostic settings for Azure Cosmos DB, see Create diagnostic settings.
- For detailed information about how to create a diagnostic setting by using the Azure portal, the Azure CLI, or PowerShell, see Create diagnostic settings to collect platform logs and metrics in Azure.