Skip to content

Commit a64d906

Browse files
authored
Merge pull request #113459 from SnehaGunda/breadcrumb
Monitoring docs linking & TOC updates
2 parents 8626cdc + af6f55f commit a64d906

File tree

4 files changed

+74
-81
lines changed

4 files changed

+74
-81
lines changed

articles/cosmos-db/TOC.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,22 +1051,26 @@
10511051
items:
10521052
- name: Monitor Cosmos DB
10531053
href: monitor-cosmos-db.md
1054-
- name: Monitor server-side latency
1055-
href: monitor-server-side-latency.md
1056-
- name: Monitor request unit usage
1057-
href: monitor-request-unit-usage.md
1058-
- name: Monitor with diagnostic logs
1059-
href: cosmosdb-monitor-resource-logs.md
1060-
- name: Audit control plane logs
1061-
href: audit-control-plane-logs.md
1062-
- name: Azure Monitor for Cosmos (preview)
1063-
href: ../azure-monitor/insights/cosmosdb-insights-overview.md?toc=/azure/cosmos-db/toc.json&bc=/azure/cosmos-db/breadcrumb/toc.json
1054+
- name : Use Azure monitor metrics
1055+
items:
1056+
- name: Azure Monitor for Cosmos (preview)
1057+
href: ../azure-monitor/insights/cosmosdb-insights-overview.md?toc=/azure/cosmos-db/toc.json&bc=/azure/cosmos-db/breadcrumb/toc.json
1058+
- name: Monitor server-side latency
1059+
href: monitor-server-side-latency.md
1060+
- name: Monitor request unit usage
1061+
href: monitor-request-unit-usage.md
1062+
- name : Use Azure monitor metrics
1063+
items:
1064+
- name: Monitor with diagnostic logs
1065+
href: cosmosdb-monitor-resource-logs.md
1066+
- name: Audit control plane logs
1067+
href: audit-control-plane-logs.md
10641068
- name: View metrics from Cosmos DB account
10651069
href: use-metrics.md
1066-
- name: Application logging with Logic Apps
1067-
href: ../logic-apps/logic-apps-scenario-error-and-exception-handling.md?toc=/azure/cosmos-db/toc.json&bc=/azure/cosmos-db/breadcrumb/toc.json
10681070
- name: Monitoring data reference
10691071
href: monitor-cosmos-db-reference.md
1072+
- name: Application logging with Logic Apps
1073+
href: ../logic-apps/logic-apps-scenario-error-and-exception-handling.md?toc=/azure/cosmos-db/toc.json&bc=/azure/cosmos-db/breadcrumb/toc.json
10701074
- name: Develop locally
10711075
items:
10721076
- name: Use the emulator

articles/cosmos-db/audit-control-plane-logs.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ The following are some example scenarios where auditing control plane operations
2323

2424
## Disable key based metadata write access
2525

26-
Before you audit the control plane operations in Azure Cosmos DB, disable the key-based metadata write access on your account. When key based metadata write access is disabled, clients connecting to the Azure Cosmos account through account keys are prevented from accessing the account. You can disable write access by setting the `disableKeyBasedMetadataWriteAccess` property to true. After you set this property, changes to any resource can happen from a user with the proper Role-based access control(RBAC) role and credentials. To learn more on how to set this property, see the [Preventing changes from SDKs](role-based-access-control.md#preventing-changes-from-cosmos-sdk) article. Once this option - disableKeyBasedMetadataWriteAccess - is switched on - SDK based clients will see an error "Operation 'POST' on resource 'ContainerNameorDatabaseName' is not allowed through Azure Cosmos DB endpoint. Please switch on such operations for your account, or perform this operation through Azure Resource Manager, Azure CLI or Azure Powershell. The way to switch back is to reset disableKeyBasedMetadataWriteAccess to false using CLI as described [here](role-based-access-control.md#preventing-changes-from-cosmos-sdk) - remember to change true to false in the cli command.
26+
Before you audit the control plane operations in Azure Cosmos DB, disable the key-based metadata write access on your account. When key based metadata write access is disabled, clients connecting to the Azure Cosmos account through account keys are prevented from accessing the account. You can disable write access by setting the `disableKeyBasedMetadataWriteAccess` property to true. After you set this property, changes to any resource can happen from a user with the proper Role-based access control(RBAC) role and credentials. To learn more on how to set this property, see the [Preventing changes from SDKs](role-based-access-control.md#preventing-changes-from-cosmos-sdk) article.
27+
28+
After the `disableKeyBasedMetadataWriteAccess` is turned on, if the SDK based clients run create or update operations, an error *"Operation 'POST' on resource 'ContainerNameorDatabaseName' is not allowed through Azure Cosmos DB endpoint* is returned. You have to turn on access to such operations for your account, or perform the create/update operations through Azure Resource Manager, Azure CLI or Azure Powershell. To switch back, set the disableKeyBasedMetadataWriteAccess to **false** by using Azure CLI as described in the [Preventing changes from Cosmos SDK](role-based-access-control.md#preventing-changes-from-cosmos-sdk) article. Make sure to change the value of `disableKeyBasedMetadataWriteAccess` to false instead of true.
2729

2830
Consider the following points when turning off the metadata write access:
2931

articles/cosmos-db/cosmosdb-monitor-resource-logs.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,40 @@ For detailed information about how to create a diagnostic setting by using the A
6868

6969
## <a id="diagnostic-queries"></a> Troubleshoot issues with diagnostics queries
7070

71+
1. How to query for the operations that are taking longer than 3 milliseconds to run:
72+
73+
```Kusto
74+
AzureDiagnostics
75+
| where toint(duration_s) > 3 and ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
76+
| summarize count() by clientIpAddress_s, TimeGenerated
77+
```
78+
79+
1. How to query for the user agent that is running the operations:
80+
81+
```Kusto
82+
AzureDiagnostics
83+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
84+
| summarize count() by OperationName, userAgent_s
85+
```
86+
87+
1. How to query for the long running operations:
88+
89+
```Kusto
90+
AzureDiagnostics
91+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
92+
| project TimeGenerated , duration_s
93+
| summarize count() by bin(TimeGenerated, 5s)
94+
| render timechart
95+
```
96+
97+
1. How to get partition Key statistics to evaluate skew across top 3 partitions for database account:
98+
99+
```Kusto
100+
AzureDiagnostics
101+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="PartitionKeyStatistics"
102+
| project SubscriptionId, regionName_s, databaseName_s, collectionname_s, partitionkey_s, sizeKb_s, ResourceId
103+
```
104+
71105
1. How to get the request charges for expensive queries?
72106

73107
```Kusto
@@ -91,6 +125,22 @@ For detailed information about how to create a diagnostic setting by using the A
91125
| where TimeGenerated >= ago(2h)
92126
| summarize max(responseLength_s), max(requestLength_s), max(requestCharge_s), count = count() by OperationName, requestResourceType_s, userAgent_s, collectionRid_s, bin(TimeGenerated, 1h)
93127
```
128+
129+
1. How to get all queries that are consuming more then 100 RU/s joined with data from **DataPlaneRequests** and **QueryRunTimeStatistics**.
130+
131+
```Kusto
132+
AzureDiagnostics
133+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" and todouble(requestCharge_s) > 100.0
134+
| project activityId_g, requestCharge_s
135+
| join kind= inner (
136+
AzureDiagnostics
137+
| where ResourceProvider =="MICROSOFT.DOCUMENTDB" and Category == "QueryRuntimeStatistics"
138+
| project activityId_g, querytext_s
139+
) on $left.activityId_g == $right.activityId_g
140+
| order by requestCharge_s desc
141+
| limit 100
142+
```
143+
94144
1. How to get the distribution for different operations?
95145

96146
```Kusto

articles/cosmos-db/monitor-cosmos-db.md

Lines changed: 5 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ ms.custom: subject-monitoring
1111
---
1212

1313
# Monitoring Azure Cosmos DB
14+
1415
When you have critical applications and business processes relying on Azure resources, you want to monitor those resources for their availability, performance, and operation. This article describes the monitoring data generated by Azure Cosmos databases and how you can use the features of Azure Monitor to analyze and alert on this data.
1516

1617
## What is Azure Monitor?
17-
Azure Cosmos DB creates monitoring data using [Azure Monitor](../azure-monitor/overview.md) which is a full stack monitoring service in Azure that provides a complete set of features to monitor your Azure resources in addition to resources in other clouds and on-premises.
18+
Azure Cosmos DB creates monitoring data using [Azure Monitor](../azure-monitor/overview.md) which is a full stack monitoring service in Azure that provides a complete set of features to monitor your Azure resources in addition to resources in other clouds and on-premises.
1819

1920
If you're not already familiar with monitoring Azure services, start with the article [Monitoring Azure resources with Azure Monitor](../azure-monitor/insights/monitor-azure-resource.md) which describes the following:
2021

@@ -27,9 +28,8 @@ If you're not already familiar with monitoring Azure services, start with the ar
2728
The following sections build on this article by describing the specific data gathered from Azure Cosmos DB and providing examples for configuring data collection and analyzing this data with Azure tools.
2829

2930
## Azure Monitor for Cosmos DB (Preview)
30-
[Azure Monitor for Azure Cosmos DB](../azure-monitor/insights/cosmosdb-insights-overview.md) is based on the [workbooks feature of Azure Monitor](../azure-monitor/app/usage-workbooks.md) and uses the same monitoring data collected for Cosmos DB described in the sections below. Use this tool for a view of the overall performance, failures, capacity, and operational health of all your Azure Cosmos DB resources in a unified interactive experience, and leverage the other features of Azure Monitor for detailed analysis and alerting.
3131

32-
![Azure Monitor for Cosmos DB](media/monitor-cosmos-db/azure-monitor-cosmos-db.png)
32+
Azure Monitor for Azure Cosmos DB is based on the [workbooks feature of Azure Monitor](../azure-monitor/app/usage-workbooks.md) and uses the same monitoring data collected for Cosmos DB described in the sections below. Use Azure Monitor for a view of the overall performance, failures, capacity, and operational health of all your Azure Cosmos DB resources in a unified interactive experience, and leverage the other features of Azure Monitor for detailed analysis and alerting. To learn more, see the [Explore Azure Monitor for Azure Cosmos DB](../azure-monitor/insights/cosmosdb-insights-overview.md) article.
3333

3434
> [!NOTE]
3535
> When creating containers, make sure you don’t create two containers with the same name but different casing. That’s because some parts of the Azure platform are not case-sensitive, and this can result in confusion/collision of telemetry and actions on containers with such names.
@@ -82,7 +82,6 @@ You can analyze metrics for Azure Cosmos DB with metrics from other Azure servic
8282
- Region
8383
- StatusCode
8484

85-
8685
## Analyzing log data
8786
Data in Azure Monitor Logs is stored in tables which each table having its own set of unique properties. Azure Cosmos DB stores data in the following tables.
8887

@@ -109,22 +108,6 @@ Following are queries that you can use to help you monitor your Azure Cosmos dat
109108
110109
```
111110
112-
* To query for the 10 most recently logged events:
113-
114-
```Kusto
115-
AzureDiagnostics
116-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
117-
| limit 10
118-
```
119-
120-
* To query for all operations, grouped by operation type:
121-
122-
```Kusto
123-
AzureDiagnostics
124-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
125-
| summarize count() by OperationName
126-
```
127-
128111
* To query for all operations, grouped by resource:
129112
130113
```Kusto
@@ -141,59 +124,13 @@ Following are queries that you can use to help you monitor your Azure Cosmos dat
141124
| where Caller == "[email protected]" and ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
142125
| summarize count() by Resource
143126
```
144-
* To get all queries greater than 100 RUs joined with data from **DataPlaneRequests** and **QueryRunTimeStatistics**.
145-
146-
```Kusto
147-
AzureDiagnostics
148-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" and todouble(requestCharge_s) > 100.0
149-
| project activityId_g, requestCharge_s
150-
| join kind= inner (
151-
AzureDiagnostics
152-
| where ResourceProvider =="MICROSOFT.DOCUMENTDB" and Category == "QueryRuntimeStatistics"
153-
| project activityId_g, querytext_s
154-
) on $left.activityId_g == $right.activityId_g
155-
| order by requestCharge_s desc
156-
| limit 100
157-
```
158-
159-
* To query for which operations take longer than 3 milliseconds:
160-
161-
```Kusto
162-
AzureDiagnostics
163-
| where toint(duration_s) > 3 and ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
164-
| summarize count() by clientIpAddress_s, TimeGenerated
165-
```
166-
167-
* To query for which agent is running the operations:
168-
169-
```Kusto
170-
AzureDiagnostics
171-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
172-
| summarize count() by OperationName, userAgent_s
173-
```
174-
175-
* To query for when the long running operations were performed:
176-
177-
```Kusto
178-
AzureDiagnostics
179-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
180-
| project TimeGenerated , duration_s
181-
| summarize count() by bin(TimeGenerated, 5s)
182-
| render timechart
183-
```
184-
185-
* To get Partition Key statistics to evaluate skew across top 3 partitions for database account:
186-
187-
```Kusto
188-
AzureDiagnostics
189-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="PartitionKeyStatistics"
190-
| project SubscriptionId, regionName_s, databaseName_s, collectionname_s, partitionkey_s, sizeKb_s, ResourceId
191-
```
192127
193128
## Monitor Azure Cosmos DB programmatically
129+
194130
The account level metrics available in the portal, such as account storage usage and total requests, are not available via the SQL APIs. However, you can retrieve usage data at the collection level by using the SQL APIs. To retrieve collection level data, do the following:
195131
196132
* To use the REST API, [perform a GET on the collection](https://msdn.microsoft.com/library/mt489073.aspx). 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.
133+
197134
* To use the .NET SDK, use the [DocumentClient.ReadDocumentCollectionAsync](https://msdn.microsoft.com/library/microsoft.azure.documents.client.documentclient.readdocumentcollectionasync.aspx) method, which returns a [ResourceResponse](https://msdn.microsoft.com/library/dn799209.aspx) that contains a number of usage properties such as **CollectionSizeUsage**, **DatabaseUsage**, **DocumentUsage**, and more.
198135
199136
To access additional metrics, use the [Azure Monitor SDK](https://www.nuget.org/packages/Microsoft.Azure.Insights). Available metric definitions can be retrieved by calling:

0 commit comments

Comments
 (0)