Skip to content

Commit af6f55f

Browse files
committed
Moving queries between docs
1 parent 93828be commit af6f55f

File tree

2 files changed

+53
-65
lines changed

2 files changed

+53
-65
lines changed

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: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ 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?
@@ -81,7 +82,6 @@ You can analyze metrics for Azure Cosmos DB with metrics from other Azure servic
8182
- Region
8283
- StatusCode
8384

84-
8585
## Analyzing log data
8686
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.
8787

@@ -108,22 +108,6 @@ Following are queries that you can use to help you monitor your Azure Cosmos dat
108108
109109
```
110110
111-
* To query for the 10 most recently logged events:
112-
113-
```Kusto
114-
AzureDiagnostics
115-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
116-
| limit 10
117-
```
118-
119-
* To query for all operations, grouped by operation type:
120-
121-
```Kusto
122-
AzureDiagnostics
123-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
124-
| summarize count() by OperationName
125-
```
126-
127111
* To query for all operations, grouped by resource:
128112
129113
```Kusto
@@ -140,59 +124,13 @@ Following are queries that you can use to help you monitor your Azure Cosmos dat
140124
| where Caller == "[email protected]" and ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
141125
| summarize count() by Resource
142126
```
143-
* To get all queries greater than 100 RUs joined with data from **DataPlaneRequests** and **QueryRunTimeStatistics**.
144-
145-
```Kusto
146-
AzureDiagnostics
147-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" and todouble(requestCharge_s) > 100.0
148-
| project activityId_g, requestCharge_s
149-
| join kind= inner (
150-
AzureDiagnostics
151-
| where ResourceProvider =="MICROSOFT.DOCUMENTDB" and Category == "QueryRuntimeStatistics"
152-
| project activityId_g, querytext_s
153-
) on $left.activityId_g == $right.activityId_g
154-
| order by requestCharge_s desc
155-
| limit 100
156-
```
157-
158-
* To query for which operations take longer than 3 milliseconds:
159-
160-
```Kusto
161-
AzureDiagnostics
162-
| where toint(duration_s) > 3 and ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
163-
| summarize count() by clientIpAddress_s, TimeGenerated
164-
```
165-
166-
* To query for which agent is running the operations:
167-
168-
```Kusto
169-
AzureDiagnostics
170-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
171-
| summarize count() by OperationName, userAgent_s
172-
```
173-
174-
* To query for when the long running operations were performed:
175-
176-
```Kusto
177-
AzureDiagnostics
178-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
179-
| project TimeGenerated , duration_s
180-
| summarize count() by bin(TimeGenerated, 5s)
181-
| render timechart
182-
```
183-
184-
* To get Partition Key statistics to evaluate skew across top 3 partitions for database account:
185-
186-
```Kusto
187-
AzureDiagnostics
188-
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="PartitionKeyStatistics"
189-
| project SubscriptionId, regionName_s, databaseName_s, collectionname_s, partitionkey_s, sizeKb_s, ResourceId
190-
```
191127
192128
## Monitor Azure Cosmos DB programmatically
129+
193130
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:
194131
195132
* 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+
196134
* 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.
197135
198136
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)