|
| 1 | +--- |
| 2 | +title: View data collection rules in Azure Monitor |
| 3 | +description: Describes different options for viewing data collection rules (DCRs) and data collection rule associations (DCRA) in Azure Monitor. |
| 4 | +ms.topic: conceptual |
| 5 | +author: bwren |
| 6 | +ms.author: bwren |
| 7 | +ms.date: 03/18/2024 |
| 8 | +ms.reviewer: nikeist |
| 9 | +--- |
| 10 | + |
| 11 | +# View data collection rules in Azure Monitor |
| 12 | +There are multiple ways to view the DCRs in your subscription and the resources that they are associated with. |
| 13 | + |
| 14 | +### [Portal](#tab/portal) |
| 15 | +To view your DCRs in the Azure portal, select **Data Collection Rules** under **Settings** on the **Monitor** menu. |
| 16 | + |
| 17 | +:::image type="content" source="media/data-collection-rule-overview/view-data-collection-rules.png" lightbox="media/data-collection-rule-overview/view-data-collection-rules.png" alt-text="Screenshot that shows DCRs in the Azure portal."::: |
| 18 | + |
| 19 | +Select a DCR to view its details, including the resources it's associated with. For some DCRs, you may need to use the **JSON view** to view its details. See [Create and edit data collection rules (DCRs) in Azure Monitor](./data-collection-rule-create-edit.md) for details on how you can modify them. |
| 20 | + |
| 21 | +> [!NOTE] |
| 22 | +> Although this view shows all DCRs in the specified subscriptions, selecting the **Create** button will create a data collection for Azure Monitor Agent. Similarly, this page will only allow you to modify DCRs for Azure Monitor Agent. For guidance on how to create and update DCRs for other workflows, see [Create and edit data collection rules (DCRs) in Azure Monitor](./data-collection-rule-create-edit.md). |
| 23 | +
|
| 24 | + |
| 25 | + |
| 26 | +### [PowerShell](#tab/powershell) |
| 27 | +Use [Get-AzDataCollectionRule](/powershell/module/az.monitor/get-azdatacollectionrule) to retrieve the DCRs in your subscription. |
| 28 | + |
| 29 | + |
| 30 | +```powershell |
| 31 | +Get-AzDataCollectionRule |
| 32 | +``` |
| 33 | + |
| 34 | +Use [Get-azDataCollectionRuleAssociation](/powershell/module/az.monitor/get-azdatacollectionruleassociation) to retrieve the DCRs associated with a VM. |
| 35 | + |
| 36 | +```powershell |
| 37 | +get-azDataCollectionRuleAssociation -TargetResourceId /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.Compute/virtualMachines/my-vm | foreach {Get-azDataCollectionRule -RuleId $_.DataCollectionRuleId } |
| 38 | +``` |
| 39 | + |
| 40 | +### [CLI](#tab/cli) |
| 41 | +Use [az monitor data-collection rule](/cli/azure/monitor/data-collection/rule) to work the DCRs using Azure CLI. |
| 42 | + |
| 43 | +Use the following to return all DCRs in your subscription. |
| 44 | + |
| 45 | +```azurecli |
| 46 | +az monitor data-collection rule list |
| 47 | +``` |
| 48 | + |
| 49 | +Use the following to return DCR associations for a VM. |
| 50 | + |
| 51 | +```azurecli |
| 52 | +az monitor data-collection rule association list --resource "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.Compute/virtualMachines/my-vm " |
| 53 | +``` |
| 54 | +--- |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +## Preview DCR experience |
| 59 | +A preview of the new Azure portal experience for DCRs is now available. Select the option on the displayed banner to enable this experience. |
| 60 | + |
| 61 | +:::image type="content" source="media/data-collection-rule-view/preview-experience.png" alt-text="Screenshot of title bar to enable the preview experience for DCRs in the Azure portal." lightbox="media/data-collection-rule-view/preview-experience.png"::: |
| 62 | + |
| 63 | +The preview experience ties together DCRs and the resources they're associated with. You can either view the list by **Data collection rule**, which shows the number of resources associated with each DCR, or by **Resources**, which shows the count of DCRs associated with each resource. |
| 64 | + |
| 65 | + |
| 66 | +### Data collection rule view |
| 67 | +In the **Data collection rule** view, the **Resource count** represents the number of resources that have a [data collection rule association](./data-collection-rule-overview.md#data-collection-rule-associations-dcra) with the DCR. Click this value to open the **Resources** view for that DCR. |
| 68 | + |
| 69 | +:::image type="content" source="media/data-collection-rule-view/data-collection-rules-view.png" alt-text="Screenshot of data collection rules view in the preview experience for DCRs in the Azure portal." lightbox="media/data-collection-rule-view/data-collection-rules-view.png"::: |
| 70 | + |
| 71 | +### Resources view |
| 72 | +The **Resources** view lists all Azure resources that match the selected filter, whether they have a DCR association or not. Tiles at the top of the view list the count of total resources listed, the number of resources not associated with a DCR, and the total number of DCRs matching the selected filter. |
| 73 | + |
| 74 | +:::image type="content" source="media/data-collection-rule-view/resources-view.png" alt-text="Screenshot of resources view in the preview experience for DCRs in the Azure portal." lightbox="media/data-collection-rule-view/resources-view.png"::: |
| 75 | + |
| 76 | +The **Data collection rules** column represents the number of DCRs that are associated with each resource. Click this value to open a new pane listing the DCRs associated with the resource. |
| 77 | + |
| 78 | +:::image type="content" source="media/data-collection-rule-view/resources-view-associations.png" alt-text="Screenshot of the DCR associations for a resource in the resources view in the preview experience for DCRs in the Azure portal." lightbox="media/data-collection-rule-view/resources-view-associations.png"::: |
| 79 | + |
| 80 | +> [!IMPORTANT] |
| 81 | +> Not all DCRs are associated with resources. For example, DCRs used with the [Logs ingestion API](../logs/logs-ingestion-api-overview.md) are specified in the API call and do not use associations. These DCRs still appear in the view, but will have a **Resource Count** of 0. |
| 82 | +
|
| 83 | +### Create new associations |
| 84 | +Using the **Resources** view, you can create new associations to one or more DCRs for a particular resource. Select the resource and then click **Associate to existing data collection rules**. |
| 85 | + |
| 86 | +:::image type="content" source="media/data-collection-rule-view/resources-view-associate.png" alt-text="Screenshot of the create association button in the resources view in the preview experience for DCRs in the Azure portal." lightbox="media/data-collection-rule-view/resources-view-associate.png"::: |
| 87 | + |
| 88 | +This opens a list of DCRs that can be associated with the current resource. This list only includes DCRs that are valid for the particular resource. For example, if the resource is a VM with the Azure Monitor agent (AMA) installed, only DCRs that process AMA data are listed. |
| 89 | + |
| 90 | +:::image type="content" source="media/data-collection-rule-view/resources-view-create-associations.png" alt-text="Screenshot of the create associations view in the resources view in the preview experience for DCRs in the Azure portal." lightbox="media/data-collection-rule-view/resources-view-create-associations.png"::: |
| 91 | + |
| 92 | +Click **Review & Associate** to create the association. |
| 93 | + |
| 94 | +## Next steps |
| 95 | +See the following articles for additional information on how to work with DCRs. |
| 96 | + |
| 97 | +- [Data collection rule structure](data-collection-rule-structure.md) for a description of the JSON structure of DCRs and the different elements used for different workflows. |
| 98 | +- [Sample data collection rules (DCRs)](data-collection-rule-samples.md) for sample DCRs for different data collection scenarios. |
| 99 | +- [Create and edit data collection rules (DCRs) in Azure Monitor](./data-collection-rule-create-edit.md) for different methods to create DCRs for different data collection scenarios. |
| 100 | +- [Azure Monitor service limits](../service-limits.md#data-collection-rules) for limits that apply to each DCR. |
0 commit comments