Skip to content

Commit bfdb69c

Browse files
committed
Changing script based on recent PowerShell changes
1 parent 6c77ed0 commit bfdb69c

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

articles/azure-monitor/essentials/data-collection-rule-create-edit.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ ms.custom: references_regions
1010
---
1111

1212
# Create and edit data collection rules (DCRs) in Azure Monitor
13+
1314
There are multiple methods for creating a [data collection rule (DCR)](./data-collection-rule-overview.md) in Azure Monitor. In some cases, Azure Monitor will create and manage the DCR according to settings that you configure in the Azure portal. In other cases, you might need to create your own DCRs to customize particular scenarios.
1415

1516
This article describes the different methods for creating and editing a DCR. For the contents of the DCR itself, see [Structure of a data collection rule in Azure Monitor](./data-collection-rule-structure.md).
1617

1718
## Permissions
19+
1820
You require the following permissions to create DCRs and associations:
1921

2022
| Built-in role | Scopes | Reason |
@@ -24,6 +26,7 @@ This article describes the different methods for creating and editing a DCR. For
2426
| Any role that includes the action *Microsoft.Resources/deployments/** | <ul><li>Subscription and/or</li><li>Resource group and/or </li><li>An existing DCR</li></ul> | Deploy Azure Resource Manager templates. |
2527

2628
## Automated methods to create a DCR
29+
2730
The following table lists methods to create data collection scenarios using the Azure portal where the DCR is created for you. In these cases you don't need to interact directly with the DCR itself.
2831

2932
| Scenario | Resources | Description |
@@ -32,7 +35,6 @@ The following table lists methods to create data collection scenarios using the
3235
| 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. |
3336
| 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 already use a DCR. |
3437

35-
3638
## Create a DCR
3739

3840
Azure provides a centralized cloud based data collection configuration plan for virtual machines, virtual machine scale sets, On-Prem machines and Prometheus metrics from containers.
@@ -47,7 +49,7 @@ To create a data collection rule using the Azure CLI, PowerShell, API, or ARM te
4749
## [Portal](#tab/portal)
4850

4951
On the **Monitor** menu, select **Data Collection Rules** > **Create** to open the page to create a new data collection rule.
50-
52+
5153
:::image type="content" source="media/data-collection-rule-create-edit/data-collection-rules-updated.png" lightbox="media/data-collection-rule-create-edit/data-collection-rules-updated.png" alt-text="Screenshot that shows the Create button on the Data Collection Rules screen." border="false":::
5254

5355
Configure the settings in each step of the wizard, as detailed below.
@@ -71,9 +73,9 @@ Configure the settings in each step of the wizard, as detailed below.
7173

7274
| Screen element | Description |
7375
|:---|:---|
74-
| **+ Add resources** | Associate virtual machines, Virtual Machine Scale Sets, and Azure Arc for servers to the data collection rule. The Azure portal installs Azure Monitor Agent on resources that don't already have the agent installed.|
75-
|**Enable Data Collection Endpoints**| If the machine you're monitoring is not in the same region as your destination Log Analytics workspace, enable data collection endpoints and select an endpoint in the region of the monitored machine to collect **Linux syslog data**, **IIS logs**, **custom text logs** or **custom JSON logs**.<br>If the monitored machine is in the same region as your destination Log Analytics workspace, or if you're collecting performance counters and Windows event logs, don't select a data collection endpoint on the **Resources** tab.<br>The data collection endpoint on the **Resources** tab is the configuration access endpoint, as described in [Components of a data collection endpoint](../essentials/data-collection-endpoint-overview.md#components-of-a-dce).<br>If you need network isolation using private links, select existing endpoints from the same region for the respective resources or [create a new endpoint](../essentials/data-collection-endpoint-overview.md).|
76-
|**Agent extension identity**| Use a system-assigned managed identity, or select an existing user-assigned identity assigned to the virtual machine. For more information, see [Managed identity types](/entra/identity/managed-identities-azure-resources/overview#managed-identity-types).|
76+
| **+ Add resources** | Associate virtual machines, Virtual Machine Scale Sets, and Azure Arc for servers to the data collection rule. The Azure portal installs Azure Monitor Agent on resources that don't already have the agent installed. |
77+
| **Enable Data Collection Endpoints** | If the machine you're monitoring is not in the same region as your destination Log Analytics workspace, enable data collection endpoints and select an endpoint in the region of the monitored machine to collect **Linux syslog data**, **IIS logs**, **custom text logs** or **custom JSON logs**.<br>If the monitored machine is in the same region as your destination Log Analytics workspace, or if you're collecting performance counters and Windows event logs, don't select a data collection endpoint on the **Resources** tab.<br>The data collection endpoint on the **Resources** tab is the configuration access endpoint, as described in [Components of a data collection endpoint](../essentials/data-collection-endpoint-overview.md#components-of-a-dce).<br>If you need network isolation using private links, select existing endpoints from the same region for the respective resources or [create a new endpoint](../essentials/data-collection-endpoint-overview.md). |
78+
| **Agent extension identity** | Use a system-assigned managed identity, or select an existing user-assigned identity assigned to the virtual machine. For more information, see [Managed identity types](/entra/identity/managed-identities-azure-resources/overview#managed-identity-types). |
7779

7880
### Collect and deliver
7981

@@ -83,8 +85,8 @@ On the **Collect and deliver** tab, select **Add data source** and configure the
8385

8486
| Screen element | Description |
8587
|:---|:---|
86-
| **Data source** | Select a **Data source type** and define related fields based on the data source type you select. For more information about collecting data from the various data source types, see [Collect data with Azure Monitor Agent](../agents/azure-monitor-agent-data-collection.md)|
87-
| **Destination** | Add one or more destinations for each source. You can select multiple destinations of the same or different types. |
88+
| **Data source** | Select a **Data source type** and define related fields based on the data source type you select. For more information about collecting data from the various data source types, see [Collect data with Azure Monitor Agent](../agents/azure-monitor-agent-data-collection.md) |
89+
| **Destination** | Add one or more destinations for each source. You can select multiple destinations of the same or different types. |
8890

8991
### Review + create
9092

@@ -104,30 +106,30 @@ az monitor data-collection rule create --location 'eastus' --resource-group 'my-
104106
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.
105107

106108
```powershell
107-
New-AzDataCollectionRule -Location 'east-us' -ResourceGroupName 'my-resource-group' -RuleName 'myDCRName' -RuleFile 'C:\MyNewDCR.json' -Description 'This is my new DCR'
109+
New-AzDataCollectionRule -Name 'myDCRName' -ResourceGroupName 'my-resource-group' -JsonFilePath 'C:\MyNewDCR.json'
108110
```
109111

110112
**Data collection rules**
111113

112-
| Action | Command |
113-
|:---|:---|
114-
| Get rules | [Get-AzDataCollectionRule](/powershell/module/az.monitor/get-azdatacollectionrule) |
115-
| Create a rule | [New-AzDataCollectionRule](/powershell/module/az.monitor/new-azdatacollectionrule) |
116-
| Update a rule | [Update-AzDataCollectionRule](/powershell/module/az.monitor/update-azdatacollectionrule) |
117-
| Delete a rule | [Remove-AzDataCollectionRule](/powershell/module/az.monitor/remove-azdatacollectionrule) |
114+
| Action | Command |
115+
|:-------------------------|:-----------------------------------------------------------------------------------------|
116+
| Get rules | [Get-AzDataCollectionRule](/powershell/module/az.monitor/get-azdatacollectionrule) |
117+
| Create a rule | [New-AzDataCollectionRule](/powershell/module/az.monitor/new-azdatacollectionrule) |
118+
| Update a rule | [Update-AzDataCollectionRule](/powershell/module/az.monitor/update-azdatacollectionrule) |
119+
| Delete a rule | [Remove-AzDataCollectionRule](/powershell/module/az.monitor/remove-azdatacollectionrule) |
118120
| Update "Tags" for a rule | [Update-AzDataCollectionRule](/powershell/module/az.monitor/update-azdatacollectionrule) |
119121

120122
**Data collection rule associations**
121123

122-
| Action | Command |
123-
|:---|:---|
124-
| Get associations | [Get-AzDataCollectionRuleAssociation](/powershell/module/az.monitor/get-azdatacollectionruleassociation) |
125-
| Create an association | [New-AzDataCollectionRuleAssociation](/powershell/module/az.monitor/new-azdatacollectionruleassociation) |
124+
| Action | Command |
125+
|:----------------------|:---------------------------------------------------------------------------------------------------------------|
126+
| Get associations | [Get-AzDataCollectionRuleAssociation](/powershell/module/az.monitor/get-azdatacollectionruleassociation) |
127+
| Create an association | [New-AzDataCollectionRuleAssociation](/powershell/module/az.monitor/new-azdatacollectionruleassociation) |
126128
| Delete an association | [Remove-AzDataCollectionRuleAssociation](/powershell/module/az.monitor/remove-azdatacollectionruleassociation) |
127129

128130
### [API](#tab/api)
129-
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.
130131

132+
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.
131133

132134
```powershell
133135
$ResourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.Insights/dataCollectionRules/my-dcr"
@@ -136,19 +138,17 @@ $DCRContent = Get-Content $FilePath -Raw
136138
Invoke-AzRestMethod -Path ("$ResourceId"+"?api-version=2022-06-01") -Method PUT -Payload $DCRContent
137139
```
138140

139-
140141
```azurecli
141142
ResourceId="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.Insights/dataCollectionRules/my-dcr"
142143
FilePath="my-dcr.json"
143144
az rest --method put --url $ResourceId"?api-version=2022-06-01" --body @$FilePath
144145
```
145146

146-
147147
### [ARM](#tab/arm)
148148

149149
See the following references for defining DCRs and associations in a template.
150-
- [Data collection rules](/azure/templates/microsoft.insights/datacollectionrules)
151-
- [Data collection rule associations](/azure/templates/microsoft.insights/datacollectionruleassociations)
150+
* [Data collection rules](/azure/templates/microsoft.insights/datacollectionrules)
151+
* [Data collection rule associations](/azure/templates/microsoft.insights/datacollectionruleassociations)
152152

153153
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`.
154154

@@ -186,6 +186,7 @@ Use the following template to create a DCR using information from [Structure of
186186
```
187187

188188
#### DCR Association -Azure VM
189+
189190
The following sample creates an association between an Azure virtual machine and a data collection rule.
190191

191192
**Bicep template file**
@@ -274,7 +275,9 @@ resource association 'Microsoft.Insights/dataCollectionRuleAssociations@2021-09-
274275
}
275276
}
276277
```
278+
277279
### DCR Association -Arc-enabled server
280+
278281
The following sample creates an association between an Azure Arc-enabled server and a data collection rule.
279282

280283
**Bicep template file**
@@ -365,8 +368,8 @@ resource association 'Microsoft.Insights/dataCollectionRuleAssociations@2021-09-
365368
```
366369
---
367370

368-
369371
## Edit a DCR
372+
370373
To edit a DCR, you can use any of the methods described in the previous section to create a DCR using a modified version of the JSON.
371374

372375
If you need to retrieve the JSON for an existing DCR, you can copy it from the **JSON View** for the DCR in the Azure portal. You can also retrieve it using an API call as shown in the following PowerShell example.
@@ -382,5 +385,5 @@ For a tutorial that walks through the process of retrieving and then editing an
382385

383386
## Next steps
384387

385-
- [Read about the detailed structure of a data collection rule](data-collection-rule-structure.md)
386-
- [Get details on transformations in a data collection rule](data-collection-transformations.md)
388+
* [Read about the detailed structure of a data collection rule](data-collection-rule-structure.md)
389+
* [Get details on transformations in a data collection rule](data-collection-transformations.md)

0 commit comments

Comments
 (0)