You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/logging.md
+54-10Lines changed: 54 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -396,61 +396,105 @@ Now that you've enabled data collection, run the following log search example by
396
396

397
397
398
398
<aid="#queries"></a>
399
-
### Queries
399
+
### CosmosDB Log Analytics queries in Azure Monitor
400
400
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).
402
402
403
403
To learn about the meaning of the data that's returned by each log search, see [Interpret your Azure Cosmos DB logs](#interpret).
404
404
405
405
* To query for all of the diagnostic logs from Azure Cosmos DB for a specified time period:
406
406
407
407
```
408
-
AzureDiagnostics | where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
408
+
AzureDiagnostics
409
+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
409
410
```
410
411
411
412
* To query for the 10 most recently logged events:
412
413
413
414
```
414
-
AzureDiagnostics | where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests" | take 10
415
+
AzureDiagnostics
416
+
| where ResourceProvider=="MICROSOFT.DOCUMENTDB" and Category=="DataPlaneRequests"
417
+
| limit 10
415
418
```
416
419
417
420
* To query for all operations, grouped by operation type:
418
421
419
422
```
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
421
426
```
422
427
423
428
* To query for all operations, grouped by **Resource**:
424
429
425
430
```
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
427
434
```
428
435
429
436
* To query for all user activity, grouped by resource:
430
437
431
438
```
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
433
442
```
434
443
> [!NOTE]
435
444
> This command is for an activity log, not a diagnostic log.
436
445
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
+
437
463
* To query for which operations take longer than 3 milliseconds:
438
464
439
465
```
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
441
469
```
442
470
443
471
* To query for which agent is running the operations:
444
472
445
473
```
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
447
477
```
448
478
449
479
* To query for when the long running operations were performed:
450
480
451
481
```
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
453
486
```
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"
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).
0 commit comments