Muokkaa

Jaa


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 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.

To learn more about diagnostic settings, see Diagnostic settings in Azure Monitor.

Note

We recommend creating the diagnostic setting in resource-specific mode (for all APIs except API for Table) following the instructions in the REST API tab. 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.

Warning

If you need to delete a resource, rename, or move a resource, or migrate it across resource groups or subscriptions, first delete its diagnostic settings. Otherwise, if you recreate this resource, the diagnostic settings for the deleted resource could be included with the new resource, depending on the resource configuration for each resource. If the diagnostics settings are included with the new resource, this resumes the collection of resource logs as defined in the diagnostic setting and sends the applicable metric and log data to the previously configured destination.

Also, it's a good practice to delete the diagnostic settings for a resource you're going to delete and don't plan on using again to keep your environment clean.

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. Enable Send to Log Analytics Workspace checkbox, 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.