Monitor Azure Cosmos DB data by using diagnostic settings in Azure
APPLIES TO: NoSQL MongoDB Cassandra Gremlin Table
Diagnostic settings in Azure are used to collect resource logs. Resources emit Azure resource Logs and provide rich, frequent data about the operation of that resource. These logs are captured per request and they're also referred to as "data plane logs". Some examples of the data plane operations include delete, insert, and readFeed. The content of these logs varies by resource type.
Platform metrics and the Activity logs are collected automatically, whereas you must create a diagnostic setting to collect resource logs or forward them outside of Azure Monitor. You can turn on diagnostic setting for Azure Cosmos DB accounts and send resource logs to the following sources:
- Log Analytics workspaces
- Data sent to Log Analytics can be written into Azure Diagnostics (legacy) or Resource-specific (preview) tables
- Event hub
- Storage Account
We recommend creating the diagnostic setting in resource-specific mode (for all APIs except API for Table) following our instructions for creating diagnostics setting via REST API. This option provides additional cost-optimizations with an improved view for handling data.
- An existing Azure Cosmos DB account.
- If you have an Azure subscription, create a new account.
- If you don't have an Azure subscription, create a free account before you begin.
- Alternatively, you can try Azure Cosmos DB free before you commit.
Create diagnostic settings
Here, we walk through the process of creating diagnostic settings for your account.
Sign into the Azure portal.
Navigate to your Azure Cosmos DB account. Open the Diagnostic settings pane under the Monitoring section, and then select Add diagnostic setting option.
In the Diagnostic settings pane, fill the form with your preferred categories. Included here's a list of log categories.
Category API Definition Key Properties DataPlaneRequests All APIs Logs back-end requests as data plane operations, which are requests executed to create, update, delete or retrieve data within the account.
MongoRequests Mongo Logs user-initiated requests from the front end to serve requests to Azure Cosmos DB for MongoDB. When you enable this category, make sure to disable DataPlaneRequests.
CassandraRequests Cassandra Logs user-initiated requests from the front end to serve requests to Azure Cosmos DB for Cassandra. When you enable this category, make sure to disable DataPlaneRequests.
GremlinRequests Gremlin Logs user-initiated requests from the front end to serve requests to Azure Cosmos DB for Gremlin. When you enable this category, make sure to disable DataPlaneRequests.
QueryRuntimeStatistics NoSQL This table details query operations executed against an API for NoSQL account. By default, the query text and its parameters are obfuscated to avoid logging personal data with full text query logging available by request.
PartitionKeyStatistics All APIs Logs the statistics of logical partition keys by representing the estimated storage size (KB) of the partition keys. This table is useful when troubleshooting storage skews. This PartitionKeyStatistics log is only emitted if the following conditions are true: 1. At least 1% of the documents in the physical partition have same logical partition key. 2. Out of all the keys in the physical partition, the PartitionKeyStatistics log captures the top three keys with largest storage size. If the previous conditions aren't met, the partition key statistics data isn't available. It's okay if the above conditions aren't met for your account, which typically indicates you have no logical partition storage skew. Note: The estimated size of the partition keys is calculated using a sampling approach that assumes the documents in the physical partition are roughly the same size. If the document sizes aren't uniform in the physical partition, the estimated partition key size may not be accurate.
PartitionKeyRUConsumption API for NoSQL Logs the aggregated per-second RU/s consumption of partition keys. This table is useful for troubleshooting hot partitions. Currently, Azure Cosmos DB reports partition keys for API for NoSQL accounts only and for point read/write and stored procedure operations.
ControlPlaneRequests All APIs Logs details on control plane operations, which include, creating an account, adding or removing a region, updating account replication settings etc.
TableApiRequests API for Table Logs user-initiated requests from the front end to serve requests to Azure Cosmos DB for Table. When you enable this category, make sure to disable DataPlaneRequests.
Once you select your Categories details, then send your Logs to your preferred destination. If you're sending Logs to a Log Analytics Workspace, make sure to select Resource specific as the Destination table.
Enable full-text query for logging query text
Enabling this feature may result in additional logging costs, for pricing details visit Azure Monitor pricing. It is recommended to disable this feature after troubleshooting.
Azure Cosmos DB provides advanced logging for detailed troubleshooting. By enabling full-text query, you're able to view the deobfuscated query for all requests within your Azure Cosmos DB account. You also give permission for Azure Cosmos DB to access and surface this data in your logs.
To learn how to query using these newly enabled features, see:
Submit and view feedback for