Azure Reference > Databases > Cosmos DB

Monitoring Azure Cosmos DB

This document provides a comprehensive guide to monitoring your Azure Cosmos DB instances, covering key metrics, tools, and best practices for ensuring performance, availability, and cost-effectiveness.

Effective monitoring is crucial for understanding the health and performance of your Azure Cosmos DB database. It helps you proactively identify potential issues, optimize resource utilization, and ensure your applications meet their performance targets.

Key Metrics to Monitor

Azure Cosmos DB exposes a rich set of metrics that provide insights into various aspects of your database's operation. Here are some of the most important ones:

Throughput and Performance Metrics

Storage Metrics

Availability and Errors

Monitoring Tools and Services

Azure provides several integrated services to help you monitor Cosmos DB:

Azure Monitor

Azure Monitor is the primary service for collecting, analyzing, and acting on telemetry from your Azure and on-premises environments. For Cosmos DB, Azure Monitor offers:

Tip:

Configure diagnostic settings to send operation and diagnostic logs to Log Analytics or storage accounts for long-term analysis and auditing.

Azure Portal

The Azure portal provides a graphical interface for monitoring your Cosmos DB accounts. The Metrics and Diagnostic logs sections within your Cosmos DB account blade offer quick access to key performance indicators and logs.

Azure CLI and PowerShell

You can use Azure Command-Line Interface (CLI) or Azure PowerShell to programmatically retrieve metrics and diagnostic logs, enabling automated monitoring and reporting.

# Example using Azure CLI to get RU consumption metric
az cosmosdb cosmos metric list --account-name <your-cosmosdb-account-name> --resource-group <your-resource-group> --metric-names DocumentRUC.Total && \
--interval-granularity 5min --timespan <start-time>/<end-time>

Setting Up Alerts

Alerts are essential for proactive issue detection. Consider setting up alerts for the following conditions:

Best Practices for Monitoring

Note:

Request Unit (RU) consumption is the primary cost driver for Cosmos DB. Monitoring RUs closely is key to managing costs effectively.

Troubleshooting Common Monitoring Issues

By implementing a robust monitoring strategy using Azure Monitor and understanding the key metrics, you can ensure your Azure Cosmos DB environment remains healthy, performant, and cost-effective.