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).
Copy file name to clipboardExpand all lines: articles/iot-pnp/quickstart-create-pnp-device-linux.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,23 +54,23 @@ You can find your _company model repository connection string_ in the [Azure Cer
54
54
55
55
## Prepare an IoT hub
56
56
57
-
You need an Azure IoT hub in your Azure subscription to complete this quickstart. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
57
+
You also need an Azure IoT hub in your Azure subscription to complete this quickstart. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin. If you don't have an IoT hub, there will be steps to create one below.
58
58
59
59
If you're using the Azure CLI locally, the `az` version should be **2.0.75** or later, the Azure Cloud Shell uses the latest version. Use the `az --version` command to check the version installed on your machine.
60
60
61
-
Add the Microsoft Azure IoT Extension for Azure CLI:
61
+
Run the following command to add the Microsoft Azure IoT Extension for Azure CLI to your Cloud Shell instance:
62
62
63
63
```azurecli-interactive
64
64
az extension add --name azure-cli-iot-ext
65
65
```
66
66
67
67
The steps in this quickstart require version **0.8.5** or later of the extension. Use the `az extension list` command to check the version you have installed, and the `az extension update` command to update if necessary.
68
68
69
-
If don't have an IoT hub, create one using the following commands, replacing `{YourIoTHubName}` with a unique name of your choice. If you're running these commands locally, first sign in to your Azure subscription using `az login`. If you're running these commands in the Azure cloud shell, you're signed in automatically:
69
+
If don't have an IoT hub, create one using the following commands, replacing `<YourIoTHubName>` with a unique name of your choice. If you're running these commands locally, first sign in to your Azure subscription using `az login`. If you're running these commands in the Azure cloud shell, you're signed in automatically:
70
70
71
71
```azurecli-interactive
72
72
az group create --name pnpquickstarts_rg --location centralus
73
-
az iot hub create --name {YourIoTHubName} \
73
+
az iot hub create --name <YourIoTHubName> \
74
74
--resource-group pnpquickstarts_rg --sku S1
75
75
```
76
76
@@ -79,23 +79,23 @@ The previous commands create a resource group called `pnpquickstarts_rg` and an
79
79
> [!IMPORTANT]
80
80
> During public preview, IoT Plug and Play features are only available on IoT hubs created in the **Central US**, **North Europe**, and **Japan East** regions.
81
81
82
-
Run the following command to create a device identity fora device called `mypnpdevice`in your IoT hub. Replace the `{YourIoTHubName}` placeholder with the name of your IoT hub:
82
+
Run the following command to create a device identity in your IoT hub. Replace the **YourIoTHubName** and **YourDevice** placeholders with your actual names.
83
83
84
84
```azurecli-interactive
85
-
az iot hub device-identity create --hub-name {YourIoTHubName} --device-id mypnpdevice
85
+
az iot hub device-identity create --hub-name <YourIoTHubName> --device-id <YourDevice>
86
86
```
87
87
88
-
Run the following commands to get the _device connection string_ forthe device you just registered. You need this connection string laterin this quickstart:
88
+
Run the following commands to get the _device connection string_ for the device you just registered.
1. In the files you downloaded, replace `<YOUR_COMPANY_NAME_HERE>` in the `@id` and `schema` fields with a unique value. Use only the characters a-z, A-Z, 0-9, and underscore. For more information, see [Digital Twin identifier format](https://github.com/Azure/IoTPlugandPlay/tree/master/DTDL#digital-twin-identifier-format).
118
118
119
119
## Generate the C code stub
120
120
121
-
Now you have a DCM and its associated interfaces, you can generate the device code that implements the model. To generate the C code stub in VS code:
121
+
Now that you have a DCM and its associated interfaces, you can generate the device code that implements the model. To generate the C code stub in VS Code:
122
122
123
-
1. With the `pnp_app` folder open in VS code, use **Ctrl+Shift+P** to open the command palette, enter **IoT Plug and Play**, and select**Generate Device Code Stub**.
123
+
1. With the `pnp_app` folder open in VS Code, use **Ctrl+Shift+P** to open the command palette, enter **IoT Plug and Play**, and select **Generate Device Code Stub**.
124
124
125
125
> [!NOTE]
126
-
> The first time you use the IoT Plug and Play Code Generator utility, it takes a few seconds to download.
126
+
> The first time you use the IoT Plug and Play Code Generator utility, it takes a few seconds to download and install automatically.
127
127
128
-
1. Choose the **SampleDevice.capabilitymodel.json** file to use to generate the device code stub.
128
+
1. Choose the **SampleDevice.capabilitymodel.json** file to use for generating the device code stub.
129
129
130
-
1. Enter the project name **sample_device**, it will be the name of your device application.
130
+
1. Enter the project name **sample_device**. This will be the name of your device application.
1. Choose **CMake Project on Linux** as your project template.
137
137
138
-
1. Choose **Via Source Code** as the way to include the SDK.
138
+
1. Choose **Via Source Code** as the way to include the device SDK.
139
139
140
-
1. VS Code opens a new window with generated device code stub files.
140
+
1. A new folder called **sample_device** is created in the same location as the DCM file, and in it are the generated device code stub files. VS Code opens a new window to display these.
1. The device application starts sending data to IoT Hub.
@@ -192,25 +192,25 @@ To validate the device code with the **az** CLI, you need to publish the files t
192
192
> [!NOTE]
193
193
> The connection string is only required the first time you connect to the repository.
194
194
195
-
1. In VS Code output window and notification, you can check the files have been published successfully.
195
+
1. In VS Code output window and notification, you can check that the files have been published successfully.
196
196
197
197
> [!NOTE]
198
198
> If you get errors on publishing the device model files, you can try use command **IoT Plug and Play: Sign out Model Repository** to sign out and go through the steps again.
199
199
200
200
### Use the Azure IoT CLI to validate the code
201
201
202
-
After the device client sample starts, you can check it's working with the Azure CLI.
202
+
After the device client sample starts, you can check that it's working with the Azure CLI.
203
203
204
204
Use the following command to view the telemetry the sample device is sending. You may need to wait a minute or two before you see any telemetry in the output:
205
205
206
206
```azurecli-interactive
207
-
az iot dt monitor-events --hub-name {your IoT hub} --device-id mypnpdevice
207
+
az iot dt monitor-events --hub-name <YourIoTHubNme>--device-id <YourDevice>
208
208
```
209
209
210
210
Use the following command to view all the properties sent by the device:
211
211
212
212
```azurecli-interactive
213
-
az iot dt list-properties --device-id mypnpdevice --hub-name {Your IoT hub name} --source private --repo-login "{Your company model repository connection string}"
213
+
az iot dt list-properties --device-id <YourDevice> --hub-name <YourIoTHubNme>--source private --repo-login "<Your company model repository connection string>"
214
214
```
215
215
216
216
## Next steps
@@ -220,4 +220,4 @@ In this quickstart, you learned how to create an IoT Plug and Play device using
220
220
To learn more about DCMs and how to create your own models, continue to the tutorial:
221
221
222
222
> [!div class="nextstepaction"]
223
-
> [Tutorial: Create a test a device capability model using Visual Studio Code](tutorial-pnp-visual-studio-code.md)
223
+
> [Tutorial: Create andtest a device capability model using Visual Studio Code](tutorial-pnp-visual-studio-code.md)
0 commit comments