Rediger

Del via


Monitor Azure Cosmos DB data using Azure Monitor Log Analytics diagnostic settings

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 are 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:

  • Azure Monitor Log Analytics workspaces
    • Data sent to Log Analytics can be written into Azure Diagnostics (legacy) or Resource-specific (preview) tables
  • Event hub
  • Storage Account

Note

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.

Prerequisites

  • An existing Azure Cosmos DB account.
  • An existing Azure Monitor Log Analytics workspace.

Create diagnostic settings

Here, we walk through the process of creating diagnostic settings for your account.

Note

The metric to logs export as a category is not currently supported.

  1. Sign in to the Azure portal.

  2. Navigate to your existing Azure Cosmos DB account.

  3. In the Monitoring section of the resource menu, select Diagnostic settings. Then, select the Add diagnostic setting option.

    Screenshot of the list of diagnostic settings with options to create new ones or edit existing ones.

    Important

    You might see a prompt to "enable full-text query [...] for more detailed logging" if the full-text query feature is not enabled in your account. You can safely ignore this warning if you do not wish to enable this feature. For more information, see enable full-text query.

  4. In the Diagnostic settings pane, name the setting example-setting and then select the QueryRuntimeStatistics category. Send the logs to a Log Analytics Workspace selecting your existing workspace. Finally, select Resource specific as the destination option.

    Screenshot of the various options to configure a diagnostic setting.

Enable full-text query for logging query text

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.

Warning

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.

  1. On the existing Azure Cosmos DB account page, select the Features option within the Settings section of the resource menu. Then, select the Diagnostics full-text query feature.

    Screenshot of the available features for an Azure Cosmos DB account.

  2. In the dialog, select Enable. This setting is applied within a few minutes. All newly ingested logs now have the full-text or PIICommand text for each request.

    Screenshot of the diagnostics full-text query feature being enabled for an Azure Cosmos DB account.