title | description | services | documentationcenter | author | manager | editor | ms.assetid | ms.service | ms.workload | ms.tgt_pltfrm | ms.devlang | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Monitor Azure Cosmos DB requests and storage | Microsoft Docs |
Learn how to monitor your Azure Cosmos DB account for performance metrics, such as requests and server errors, and usage metrics, such as storage consumption. |
cosmos-db |
mimig1 |
jhubbard |
cgronlun |
4c6a2e6f-6e78-48e3-8dc6-f4498b235a9e |
cosmos-db |
data-services |
na |
na |
article |
09/19/2017 |
mimig |
You can monitor your Azure Cosmos DB accounts in the Azure portal. For each Azure Cosmos DB account, a full suite of metrics is available to monitor throughput, storage, availability, latency, and consistency.
Metrics can be reviewed on the Account page, the new Metrics page, or in Azure Monitor.
-
In the Azure portal, click More Services, scroll to Databases, click Azure Cosmos DB, and then click the name of the Azure Cosmos DB account for which you would like to view performance metrics.
-
When the new page loads, in the resource menu, under Monitoring, click Metrics.
-
When the Metrics page opens, select the collection to review from the Collection(s) drop-down.
The Azure portal displays the suite of collection metrics available. Note that throughput, storage, availability, latency, and consistency metrics are provided on separate tabs. To get additional detail on the metrics provided, click on the double-arrow in the top right of each metrics pane.
- In the Azure portal, click Monitor on the left bar.
- In the resource menu, click Metrics.
- In the Monitor - Metrics window, in the Resource group drop-down menu, select the resource group associated with the Azure Cosmos DB account that you'd like to monitor.
- In the Resource drop-down menu, select the database account to monitor.
- In the list of Available metrics, select the metrics to display. Use the CTRL button to multi-select.
-
In the Azure portal, click More Services, scroll to Databases, click Azure Cosmos DB, and then click the name of the Azure Cosmos DB account for which you would like to view performance metrics.
-
The Monitoring lens displays the following tiles by default:
- Total requests for the current day.
- Storage used.
-
Clicking on the double-arrow in the top-right of the Requests tile opens a detailed Metric page.
-
The Metric page shows you details about the total requests.
-
In the Azure portal, click More Services, click Azure Cosmos DB, and then click the name of the Azure Cosmos DB account for which you would like to set up performance metric alerts.
-
In the resource menu, click Alert Rules to open the Alert rules page.
-
In the Add an alert rule page, specify:
- The name of the alert rule you are setting up.
- A description of the new alert rule.
- The metric for the alert rule.
- The condition, threshold, and period that determine when the alert activates. For example, a server error count greater than 5 over the last 15 minutes.
- Whether the service administrator and coadministrators are emailed when the alert fires.
- Additional email addresses for alert notifications.
The account level metrics available in the portal, such as account storage usage and total requests, are not available via the DocumentDB APIs. However, you can retrieve usage data at the collection level by using the DocumentDB APIs. To retrieve collection level data, do the following:
- To use the REST API, perform a GET on the collection. The quota and usage information for the collection is returned in the x-ms-resource-quota and x-ms-resource-usage headers in the response.
- To use the .NET SDK, use the DocumentClient.ReadDocumentCollectionAsync method, which returns a ResourceResponse that contains a number of usage properties such as CollectionSizeUsage, DatabaseUsage, DocumentUsage, and more.
To access additional metrics, use the Azure Monitor SDK. Available metric definitions can be retrieved by calling:
https://management.azure.com/subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroup}/providers/Microsoft.DocumentDb/databaseAccounts/{DocumentDBAccountName}/metricDefinitions?api-version=2015-04-08
Queries to retrieve individual metrics use the following format:
https://management.azure.com/subscriptions/{SubecriptionId}/resourceGroups/{ResourceGroup}/providers/Microsoft.DocumentDb/databaseAccounts/{DocumentDBAccountName}/metrics?api-version=2015-04-08&$filter=%28name.value%20eq%20%27Total%20Requests%27%29%20and%20timeGrain%20eq%20duration%27PT5M%27%20and%20startTime%20eq%202016-06-03T03%3A26%3A00.0000000Z%20and%20endTime%20eq%202016-06-10T03%3A26%3A00.0000000Z
For more information, see Retrieving Resource Metrics via the Azure Monitor REST API. Note that "Azure Insights" was renamed "Azure Monitor". This blog entry refers to the older name.
To learn more about Azure Cosmos DB capacity planning, see the Azure Cosmos DB capacity planner calculator.