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/azure-monitor/essentials/data-collection-rule-create-edit.md
+188-7Lines changed: 188 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,30 +32,29 @@ The following table lists methods to create data collection scenarios using the
32
32
||[Enable VM insights overview](../vm/vminsights-enable-overview.md)| When you enable VM insights on a VM, the Azure Monitor agent is installed, and a DCR is created that collects a predefined set of performance counters. You shouldn't modify this DCR. |
33
33
| Container insights |[Enable Container insights](../containers/kubernetes-monitoring-enable.md#enable-prometheus-and-grafana)| When you enable Container insights on a Kubernetes cluster, a containerized version of the Azure Monitor agent is installed, and a DCR is created that collects data according to the configuration you selected. You may need to modify this DCR to add a transformation. |
34
34
| Text or JSON logs |[Collect logs from a text or JSON file with Azure Monitor Agent](../agents/data-collection-text-log.md?tabs=portal)| Use the Azure portal to create a DCR to collect entries from a text log on a machine with Azure Monitor Agent. |
35
-
| Workspace transformation |[Add a transformation in a workspace data collection rule using the Azure portal](../logs/tutorial-workspace-transformations-portal.md)| Create a transformation for any supported table in a Log Analytics workspace. The transformation is defined in a DCR that's then associated with the workspace. It's applied to any data sent to that table from a legacy workload that doesn't use a DCR. |
36
35
37
36
38
37
## Manually create a DCR
39
38
To manually create a DCR, create a JSON file using the appropriate configuration for the data collection that you're configuring. Start with one of the [sample DCRs](./data-collection-rule-samples.md) and use information in [Structure of a data collection rule in Azure Monitor](./data-collection-rule-structure.md) to modify the JSON file for your particular environment and requirements.
40
39
41
40
Once you have the JSON file created, you can use any of the following methods to create the DCR:
42
41
43
-
## [CLI](#tab/CLI)
42
+
###[CLI](#tab/CLI)
44
43
Use the [az monitor data-collection rule create](/cli/azure/monitor/data-collection/rule) command to create a DCR from your JSON file using the Azure CLI as shown in the following example.
45
44
46
45
```azurecli
47
46
az monitor data-collection rule create --location 'eastus' --resource-group 'my-resource-group' --name 'myDCRName' --rule-file 'C:\MyNewDCR.json' --description 'This is my new DCR'
48
47
```
49
48
50
-
## [PowerShell](#tab/powershell)
49
+
###[PowerShell](#tab/powershell)
51
50
Use the [New-AzDataCollectionRule](/powershell/module/az.monitor/new-azdatacollectionrule) cmdlet to create the DCR from your JSON file using PowerShell as shown in the following example.
52
51
53
52
```powershell
54
53
New-AzDataCollectionRule -Location 'east-us' -ResourceGroupName 'my-resource-group' -RuleName 'myDCRName' -RuleFile 'C:\MyNewDCR.json' -Description 'This is my new DCR'
55
54
```
56
55
57
56
58
-
## [API](#tab/api)
57
+
###[API](#tab/api)
59
58
Use the [DCR create API](/rest/api/monitor/data-collection-rules/create) to create the DCR from your JSON file. You can use any method to call a REST API as shown in the following examples.
60
59
61
60
@@ -74,10 +73,15 @@ az rest --method put --url $ResourceId"?api-version=2022-06-01" --body @$FilePat
74
73
```
75
74
76
75
77
-
## [ARM](#tab/arm)
78
-
Using an ARM template, you can define parameters so you can provide particular values at the time you install the DCR. This allows you to use a single template for multiple installations. Use the following template, copying in the JSON for your DCR and adding any other parameters you want to use.
76
+
### [ARM](#tab/arm)
79
77
80
-
See [Deploy the sample templates](../resource-manager-samples.md#deploy-the-sample-templates) for different methods to deploy ARM templates.
78
+
### DCR
79
+
80
+
See the follow references for defining DCRs and associations in a template.
Use the following template to create a DCR using information from [Structure of a data collection rule in Azure Monitor](./data-collection-rule-structure.md) and [Sample data collection rules (DCRs) in Azure Monitor](./data-collection-rule-samples.md) to define the `dcr-properties`.
81
85
82
86
```json
83
87
{
@@ -110,6 +114,183 @@ See [Deploy the sample templates](../resource-manager-samples.md#deploy-the-samp
110
114
]
111
115
}
112
116
117
+
```
118
+
119
+
### DCR Association -Azure VM
120
+
121
+
#### Bicep
122
+
123
+
```bicep
124
+
@description('The name of the virtual machine.')
125
+
param vmName string
126
+
127
+
@description('The name of the association.')
128
+
param associationName string
129
+
130
+
@description('The resource ID of the data collection rule.')
131
+
param dataCollectionRuleId string
132
+
133
+
resource vm 'Microsoft.Compute/virtualMachines@2021-11-01' existing = {
134
+
name: vmName
135
+
}
136
+
137
+
resource association 'Microsoft.Insights/dataCollectionRuleAssociations@2021-09-01-preview' = {
138
+
name: associationName
139
+
scope: vm
140
+
properties: {
141
+
description: 'Association of data collection rule. Deleting this association will break the data collection for this virtual machine.'
Copy file name to clipboardExpand all lines: articles/azure-monitor/essentials/data-collection-transformations-workspace.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,10 +26,11 @@ See [Tables that support transformations in Azure Monitor Logs](../logs/tables-f
26
26
See the following tutorials for creating a workspace transformation DCR:
27
27
28
28
-[Add workspace transformation to Azure Monitor Logs by using the Azure portal](../logs/tutorial-workspace-transformations-portal.md)
29
-
-[Add workspace transformation to Azure Monitor Logs by using Resource Manager templates](../logs/tutorial-workspace-transformations-api.md)|
29
+
-[Add workspace transformation to Azure Monitor Logs by using Resource Manager templates](../logs/tutorial-workspace-transformations-api.md)
30
30
31
31
32
32
## Next steps
33
33
34
-
[Create a data collection rule](../agents/data-collection-rule-azure-monitor-agent.md) and an association to it from a virtual machine by using Azure Monitor Agent.
34
+
-[Use the Azure portal to create a workspace transformation DCR.](../logs/tutorial-workspace-transformations-api.md)
35
+
-[Use ARM templates to create a workspace transformation DCR.](../logs/tutorial-workspace-transformations-portal.md)
0 commit comments