Skip to content

Commit 3e56892

Browse files
authored
Merge pull request #95481 from kanshiG/patch-66
Added queries and changed the format
2 parents ccf424f + 75ad0a2 commit 3e56892

File tree

1 file changed

+54
-10
lines changed

1 file changed

+54
-10
lines changed

articles/cosmos-db/logging.md

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,61 +396,105 @@ Now that you've enabled data collection, run the following log search example by
396396
![Sample log search for the 10 most recent logs](./media/logging/log-analytics-query.png)
397397

398398
<a id="#queries"></a>
399-
### Queries
399+
### CosmosDB Log Analytics queries in Azure Monitor
400400

401-
Here are some additional queries that you can enter into the **Log search** box to help you monitor your Azure Cosmos containers. These queries work with the [new language](../log-analytics/log-analytics-log-search-upgrade.md).
401+
Here are some additional queries that you can enter into the **Log search** box to help you monitor your Azure Cosmos containers. These queries work with the [new language](../log-analytics/log-analytics-log-search-upgrade.md).
402402

403403
To learn about the meaning of the data that's returned by each log search, see [Interpret your Azure Cosmos DB logs](#interpret).
404404

405405
* To query for all of the diagnostic logs from Azure Cosmos DB for a specified time period:
406406

407407
```
408-
AzureDiagnostics | where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
408+
AzureDiagnostics
409+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
409410
```
410411
411412
* To query for the 10 most recently logged events:
412413
413414
```
414-
AzureDiagnostics | where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" | take 10
415+
AzureDiagnostics
416+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
417+
| limit 10
415418
```
416419
417420
* To query for all operations, grouped by operation type:
418421
419422
```
420-
AzureDiagnostics | where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" | summarize count() by OperationName
423+
AzureDiagnostics
424+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
425+
| summarize count() by OperationName
421426
```
422427
423428
* To query for all operations, grouped by **Resource**:
424429
425430
```
426-
AzureActivity | where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" | summarize count() by Resource
431+
AzureActivity
432+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
433+
| summarize count() by Resource
427434
```
428435
429436
* To query for all user activity, grouped by resource:
430437
431438
```
432-
AzureActivity | where Caller == "[email protected]" and ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" | summarize count() by Resource
439+
AzureActivity
440+
| where Caller == "[email protected]" and ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
441+
| summarize count() by Resource
433442
```
434443
> [!NOTE]
435444
> This command is for an activity log, not a diagnostic log.
436445
446+
* To get all queries greater than 100 RUs joined with data from DataPlaneRequests and QueryRunTimeStatistics
447+
448+
```
449+
AzureDiagnostics
450+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" and todouble(requestCharge_s) > 100.0
451+
| project activityId_g, requestCharge_s
452+
| join kind= inner (
453+
AzureDiagnostics
454+
| where ResourceProvider =="MICROSOFT.DOCUMENTDB" and Category == "QueryRuntimeStatistics"
455+
| project activityId_g, querytext_s
456+
) on $left.activityId_g == $right.activityId_g
457+
| order by requestCharge_s desc
458+
| limit 100
459+
```
460+
461+
462+
437463
* To query for which operations take longer than 3 milliseconds:
438464
439465
```
440-
AzureDiagnostics | where toint(duration_s) > 3 and ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" | summarize count() by clientIpAddress_s, TimeGenerated
466+
AzureDiagnostics
467+
| where toint(duration_s) > 3 and ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
468+
| summarize count() by clientIpAddress_s, TimeGenerated
441469
```
442470
443471
* To query for which agent is running the operations:
444472
445473
```
446-
AzureDiagnostics | where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" | summarize count() by OperationName, userAgent_s
474+
AzureDiagnostics
475+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
476+
| summarize count() by OperationName, userAgent_s
447477
```
448478
449479
* To query for when the long running operations were performed:
450480
451481
```
452-
AzureDiagnostics | where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" | project TimeGenerated , duration_s | render timechart
482+
AzureDiagnostics
483+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
484+
| project TimeGenerated , duration_s
485+
| render timechart
453486
```
487+
488+
* To get Partition Key statistics to evaluate skew across top 3 partitions for database account:
489+
490+
```
491+
AzureDiagnostics
492+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="PartitionKeyStatistics"
493+
| project SubscriptionId, regionName_s, databaseName_s, collectionname_s, partitionkey_s, sizeKb_s, ResourceId
494+
495+
496+
```
497+
454498
455499
For more information about how to use the new Log Search language, see [Understand log searches in Azure Monitor logs](../log-analytics/log-analytics-log-search-new.md).
456500

0 commit comments

Comments
 (0)