Skip to content

Commit 545a68a

Browse files
Merge pull request #230459 from JustPies/jprefresh-3-10
Freshness Pass User Story: 2036619 Monitor and debug with insights in Azure Cosmos DB
2 parents ecd0e36 + 5bde43f commit 545a68a

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

articles/cosmos-db/use-metrics.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
---
22
title: Monitor and debug with insights in Azure Cosmos DB
3-
description: Use metrics in Azure Cosmos DB to debug common issues and monitor the database.
3+
description: Learn how to use metrics and insights in Azure Cosmos DB to debug common issues and monitor the database.
44
ms.author: esarroyo
55
author: StefArroyo
66
ms.reviewer: mjbrown
77
ms.service: cosmos-db
88
ms.subservice: nosql
99
ms.topic: how-to
10-
ms.date: 11/08/2021
10+
ms.date: 03/13/2023
1111
ms.custom: devx-track-csharp, ignite-2022
1212
---
13+
1314
# Monitor and debug with insights in Azure Cosmos DB
15+
1416
[!INCLUDE[NoSQL, MongoDB, Cassandra, Gremlin, Table](includes/appliesto-nosql-mongodb-cassandra-gremlin-table.md)]
1517

16-
Azure Cosmos DB provides insights for throughput, storage, consistency, availability, and latency. The Azure portal provides an aggregated view of these metrics. You can also view Azure Cosmos DB metrics from Azure Monitor API. The dimension values for the metrics such as container name are case-insensitive. So you need to use case-insensitive comparison when doing string comparisons on these dimension values. To learn about how to view metrics from Azure monitor, see the [Get metrics from Azure Monitor](./monitor.md) article.
18+
Azure Cosmos DB provides insights for throughput, storage, consistency, availability, and latency. The Azure portal provides an aggregated view of these metrics. You can also view Azure Cosmos DB metrics from Azure Monitor API. The dimension values for the metrics such as container name are case-insensitive. Therefore, you need to use case-insensitive comparison when doing string comparisons on these dimension values. To learn how to view metrics from Azure monitor, see [Monitor Azure Cosmos DB](./monitor.md).
1719

1820
This article walks through common use cases and how Azure Cosmos DB insights can be used to analyze and debug these issues. By default, the metric insights are collected every five minutes and are kept for seven days.
1921

@@ -23,57 +25,57 @@ This article walks through common use cases and how Azure Cosmos DB insights can
2325

2426
1. You can view your account metrics either from the **Metrics** pane or the **Insights** pane.
2527

26-
* **Metrics:** This pane provides numerical metrics that are collected at regular intervals and describe some aspect of a system at a particular time. For example, you can view and monitor the [server side latency metric](monitor-server-side-latency.md), [normalized request unit usage metric](monitor-normalized-request-units.md) etc.
28+
* **Metrics:** This pane provides numerical metrics that are collected at regular intervals and describes some aspect of a system at a particular time. For example, you can view and monitor the [server side latency metric](monitor-server-side-latency.md), [normalized request unit usage metric](monitor-normalized-request-units.md), etc.
2729

28-
* **Insights:** This pane provides a customized monitoring experience for Azure Cosmos DB. They use the same metrics and logs that are collected in Azure Monitor and shows an aggregated view for your account.
30+
* **Insights:** This pane provides a customized monitoring experience for Azure Cosmos DB. Insights use the same metrics and logs that are collected in Azure Monitor and show an aggregated view for your account.
2931

30-
1. Open the **Insights** pane. By default, the Insights pane shows the throughput, requests, storage, availability, latency, system, and account management metrics for every container in your account. You can select the **Time Range**, **Database**, and **Container** for which you want to view insights. The **Overview** tab shows RU/s usage, data usage, index usage, throttled requests, and normalized RU/s consumption for the selected database and container.
32+
1. Open the **Insights** pane. By default, the Insights pane shows the throughput, requests, storage, availability, latency, system, and management operations metrics for every container in your account. You can select the **Time Range**, **Database**, and **Container** for which you want to view insights. The **Overview** tab shows RU/s usage, data usage, index usage, throttled requests, and normalized RU/s consumption for the selected database and container.
3133

32-
:::image type="content" source="./media/use-metrics/performance-metrics.png" alt-text="Azure Cosmos DB performance metrics in Azure portal" lightbox="./media/use-metrics/performance-metrics.png" :::
34+
:::image type="content" source="./media/use-metrics/performance-metrics.png" alt-text="Screenshot of Azure Cosmos DB performance metrics in the Azure portal." lightbox="./media/use-metrics/performance-metrics.png" :::
3335

3436
1. The following metrics are available from the **Insights** pane:
3537

36-
* **Throughput** - This tab shows the total number of request units consumed or failed (429 response code) because the throughput or storage capacity provisioned for the container has exceeded.
38+
* **Throughput**. This tab shows the total number of request units consumed or failed (429 response code) because the throughput or storage capacity provisioned for the container has exceeded.
3739

38-
* **Requests** - This tab shows the total number of requests processed by status code, by operation type, and the count of failed requests (429 response code). Requests fail when the throughput or storage capacity provisioned for the container exceeds.
40+
* **Requests**. This tab shows the total number of requests processed by status code, by operation type, and the count of failed requests (429 response code). Requests fail when the throughput or storage capacity provisioned for the container exceeds.
3941

40-
* **Storage** - This tab shows the size of data and index usage over the selected time period.
42+
* **Storage**. This tab shows the size of data and index usage over the selected time period.
4143

42-
* **Availability** - This tab shows the percentage of successful requests over the total requests per hour. The success rate is defined by the Azure Cosmos DB SLAs.
44+
* **Availability**. This tab shows the percentage of successful requests over the total requests per hour. The Azure Cosmos DB SLAs defines the success rate.
4345

44-
* **Latency** - This tab shows the read and write latency observed by Azure Cosmos DB in the region where your account is operating. You can visualize latency across regions for a geo-replicated account. You can also view server-side latency by different operations. This metric doesn't represent the end-to-end request latency.
46+
* **Latency**. This tab shows the read and write latency observed by Azure Cosmos DB in the region where your account is operating. You can visualize latency across regions for a geo-replicated account. You can also view server-side latency by different operations. This metric doesn't represent the end-to-end request latency.
4547

46-
* **System** - This tab shows how many metadata requests are served by the primary partition. It also helps to identify the throttled requests.
48+
* **System**. This tab shows how many metadata requests that the primary partition serves. It also helps to identify the throttled requests.
4749

48-
* **Account management** - This tab shows the metrics for account management activities such as account creation, deletion, key updates, network and replication settings.
50+
* **Management Operations**. This tab shows the metrics for account management activities such as account creation, deletion, key updates, network and replication settings.
4951

5052
The following sections explain common scenarios where you can use Azure Cosmos DB metrics.
5153

5254
## Understand how many requests are succeeding or causing errors
5355

54-
To get started, head to the [Azure portal](https://portal.azure.com) and navigate to the **Insights** blade. From this blade, open the **Requests** tab, it shows a chart with the total requests segmented by the status code and operation type. For more information about HTTP status codes, see [HTTP status codes for Azure Cosmos DB](/rest/api/cosmos-db/http-status-codes-for-cosmosdb).
56+
To get started, head to the [Azure portal](https://portal.azure.com) and navigate to the **Insights** pane. From this pane, open the **Requests** tab. The Requests tab shows a chart with the total requests segmented by the status code and operation type. For more information about HTTP status codes, see [HTTP status codes for Azure Cosmos DB](/rest/api/cosmos-db/http-status-codes-for-cosmosdb).
5557

56-
The most common error status code is 429 (rate limiting/throttling). This error means that requests to Azure Cosmos DB are more than the provisioned throughput. The most common solution to this problem is to [scale up the RUs](./set-throughput.md) for the given collection.
58+
The most common error status code is 429 (rate limiting/throttling). This error means that requests to Azure Cosmos DB are more than the provisioned throughput. The most common solution to this problem is to scale up the RUs for the given collection. For more information, see [Introduction to provisioned throughput in Azure Cosmos DB](./set-throughput.md)
5759

58-
:::image type="content" source="media/use-metrics/request-count.png" alt-text="Number of requests per minute" lightbox= "media/use-metrics/request-count.png":::
60+
:::image type="content" source="media/use-metrics/request-count.png" alt-text="Screenshot showing total requests by status code, throttled requests, and total requests by operation type." lightbox="media/use-metrics/request-count.png":::
5961

6062
## Determine the throughput consumption by a partition key range
6163

62-
Having a good cardinality of your partition keys is essential for any scalable application. To determine the throughput distribution of any partitioned container broken down by partition key range IDs, navigate to the **Insights** pane. Open the **Throughput** tab, the normalized RU/s consumption across different partition key ranges is shown in the chart.
64+
Having a good cardinality of your partition keys is essential for any scalable application. To determine the throughput distribution of any partitioned container broken down by partition key range IDs, navigate to the **Insights** pane. Open the **Throughput** tab. The normalized RU/s consumption across different partition key ranges is shown in the chart.
6365

64-
:::image type="content" source="media/use-metrics/throughput-consumption-partition-key-range.png" alt-text="Normalized throughput consumption by partition key range IDs" lightbox="media/use-metrics/throughput-consumption-partition-key-range.png":::
66+
:::image type="content" source="media/use-metrics/throughput-consumption-partition-key-range.png" alt-text="Screenshot of the Throughput tab, showing the RU/s consumption." lightbox="media/use-metrics/throughput-consumption-partition-key-range.png":::
6567

66-
With the help of this chart, you can identify if there is a hot partition. An uneven throughput distribution may cause *hot* partitions, which can result in throttled requests and may require repartitioning. After identifying which partition key is causing the skew in distribution, you may have to repartition your container with a more distributed partition key. For more information about partitioning in Azure Cosmos DB, see [Partition and scale in Azure Cosmos DB](./partitioning-overview.md).
68+
With the help of this chart, you can identify if there's a hot partition. An uneven throughput distribution might cause *hot* partitions, which can result in throttled requests and might require repartitioning. After identifying which partition key is causing the skew in distribution, you might have to repartition your container with a more distributed partition key. For more information about partitioning in Azure Cosmos DB, see [Partitioning and horizontal scaling in Azure Cosmos DB](./partitioning-overview.md).
6769

6870
## Determine the data and index usage
6971

70-
It's important to determine the storage distribution of any partitioned container by data usage, index usage, and document usage. You can minimize the index usage, maximize the data usage and optimize your queries. To get this data, navigate to the **Insights** pane and open the **Storage** tab:
72+
It's important to determine the storage distribution of any partitioned container by data usage, index usage, and document usage. You can minimize the index usage, maximize the data usage, and optimize your queries. To get this data, navigate to the **Insights** pane and open the **Storage** tab.
7173

72-
:::image type="content" source="media/use-metrics/data-index-consumption.png" alt-text="Data, index, and document consumption" lightbox="media/use-metrics/data-index-consumption.png" :::
74+
:::image type="content" source="media/use-metrics/data-index-consumption.png" alt-text="Screenshot of the Insights pane, highlighting the Storage tab." lightbox="media/use-metrics/data-index-consumption.png" :::
7375

7476
## Compare data size against index size
7577

76-
In Azure Cosmos DB, the total consumed storage is the combination of both the Data size and Index size. Typically, the index size is a fraction of the data size. To learn more, see the [Index size](index-policy.md#index-size) article. In the Metrics blade in the [Azure portal](https://portal.azure.com), the Storage tab showcases the breakdown of storage consumption based on data and index.
78+
In Azure Cosmos DB, the total consumed storage is the combination of both the data size and index size. Typically, the index size is a fraction of the data size. To learn more, see the [Index size](index-policy.md#index-size) article. In the Metrics pane in the [Azure portal](https://portal.azure.com), the Storage tab showcases the breakdown of storage consumption based on data and index.
7779

7880
```csharp
7981
// Measure the document size usage (which includes the index size)
@@ -83,7 +85,7 @@ ResourceResponse<DocumentCollection> collectionInfo = await client.ReadDocumentC
8385

8486
If you would like to conserve index space, you can adjust the [indexing policy](index-policy.md).
8587

86-
## Debug why queries are running slow
88+
## Debug slow queries
8789

8890
In the API for NoSQL SDKs, Azure Cosmos DB provides query execution statistics.
8991

@@ -104,12 +106,11 @@ FeedResponse<dynamic> result = await query.ExecuteNextAsync();
104106
IReadOnlyDictionary<string, QueryMetrics> metrics = result.QueryMetrics;
105107
```
106108

107-
*QueryMetrics* provides details on how long each component of the query took to execute. The most common root cause for long running queries is scans, meaning the query was unable to leverage the indexes. This problem can be resolved with a better filter condition.
109+
*QueryMetrics* provides details on how long each component of the query took to execute. The most common root cause for long running queries is scans, meaning the query was unable to apply the indexes. This problem can be resolved with a better filter condition.
108110

109111
## Next steps
110112

111-
You've now learned how to monitor and debug issues using the metrics provided in the Azure portal. You may want to learn more about improving database performance by reading the following articles:
113+
You might want to learn more about improving database performance by reading the following articles:
112114

113-
* To learn about how to view metrics from Azure monitor, see the [Get metrics from Azure Monitor](./monitor.md) article.
114-
* [Performance and scale testing with Azure Cosmos DB](performance-testing.md)
115-
* [Performance tips for Azure Cosmos DB](performance-tips.md)
115+
* [Measure Azure Cosmos DB for NoSQL performance with a benchmarking framework](performance-testing.md)
116+
* [Performance tips for Azure Cosmos DB and .NET SDK v2](performance-tips.md)

0 commit comments

Comments
 (0)