Monitor Azure Cosmos DB for MongoDB vCore diagnostics logs with Azure Monitor
APPLIES TO: MongoDB vCore
Azure's diagnostic logs are essential to capture Azure resource logs for an Azure Cosmos DB for MongoDB vCore account. These logs furnish detailed and frequent insights into the operations for resources with the account.
Important
This feature is not available with M25
(burstable) or M30
(free-tier) SKUs.
Prerequisites
- An existing Azure Cosmos DB for MongoDB vCore cluster.
- If you don't have an Azure subscription, create an account for free.
- If you have an existing Azure subscription, create a new Azure Cosmos DB for MongoDB vCore cluster.
- An existing Log Analytics workspace or Azure Storage account.
Create diagnostic settings
Platform metrics and activity logs are gathered automatically. To collect resource logs and route them externally from Azure Monitor, you must establish a diagnostic setting. To learn how, see Create diagnostic settings in Azure Monitor.
Manage diagnostic settings
Sometimes you need to manage settings by finding or removing them. The az monitor diagnostic-settings
command group includes subcommands for the management of diagnostic settings.
List all diagnostic settings associated with the API for MongoDB vCore cluster.
az monitor diagnostic-settings list \ --resource-group $resourceGroupName \ --resource $clusterResourceId
Delete a specific setting using the associated resource and the name of the setting.
az monitor diagnostic-settings delete \ --resource-group $resourceGroupName \ --name $diagnosticSettingName \ --resource $clusterResourceId
Use advanced diagnostics queries
Use these resource-specific queries to perform common troubleshooting research in an API for MongoDB vCore cluster.
Important
This section assumes that you are using a Log Analytics workspace with resource-specific logs.
Navigate to Logs section of the API for MongoDB vCore cluster. Observe the list of sample queries.
Run this query to count the number of failed API for MongoDB vCore requests grouped by error code.
VCoreMongoRequests // Time range filter: | where TimeGenerated between (StartTime .. EndTime) // Resource id filter: | where _ResourceId == "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/my-resource-group-name/providers/microsoft.documentdb/mongoclusters/my-cluster-name" | where ErrorCode != 0 | summarize count() by bin(TimeGenerated, 5m), ErrorCode=tostring(ErrorCode)
Run this query to get the API for MongoDB vCore requests
P99
runtime duration by operation name.// Mongo vCore requests P99 duration by operation // Mongo vCore requests P99 runtime duration by operation name. VCoreMongoRequests // Time range filter: | where TimeGenerated between (StartTime .. EndTime) // Resource id filter: | where _ResourceId == "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/my-resource-group-name/providers/microsoft.documentdb/mongoclusters/my-cluster-name" | summarize percentile(DurationMs, 99) by bin(TimeGenerated, 1h), OperationName
Run this query to get the count of API for MongoDB vCore requests grouped by total runtime duration.
// Mongo vCore requests binned by duration // Count of Mongo vCore requests binned by total runtime duration. VCoreMongoRequests // Time range filter: | where TimeGenerated between (StartTime .. EndTime) // Resource id filter: | where _ResourceId == "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/my-resource-group-name/providers/microsoft.documentdb/mongoclusters/my-cluster-name" | project TimeGenerated, DurationBin=tostring(bin(DurationMs, 5)) | summarize count() by bin(TimeGenerated, 1m), tostring(DurationBin)
Run this query to get the count of API for MongoDB vCore requests by user agent.
// Mongo vCore requests by user agent // Count of Mongo vCore requests by user agent. VCoreMongoRequests // Time range filter: | where TimeGenerated between (StartTime .. EndTime) // Resource id filter: | where _ResourceId == "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/my-resource-group-name/providers/microsoft.documentdb/mongoclusters/my-cluster-name" | summarize count() by bin(TimeGenerated, 1h), UserAgent
Related content
- Read more about feature compatibility with MongoDB.
- Review options for migrating from MongoDB to Azure Cosmos DB for MongoDB vCore
- Get started by creating an account.