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.
To create a data collection rule using the Azure CLI, PowerShell, API, or ARM templates, create a JSON file, starting with one of the sample DCRs. Use information in Structure of a data collection rule in Azure Monitor to modify the JSON file for your particular environment and requirements.
Create with Azure portal
The Azure portal provides a simplified experience for creating a DCR for virtual machines and virtual machine scale sets. Using this method, you don't need to understand the structure of a DCR unless you want to implement an advanced feature such as a transformation. The process for creating this DCR with various data sources is described in Collect data with Azure Monitor Agent.
Important
Create your data collection rule in the same region as your destination Log Analytics workspace or Azure Monitor workspace. You can associate the data collection rule to machines or containers from any subscription or resource group in the tenant. To send data across tenants, you must first enable Azure Lighthouse.
On the Monitor menu in the Azure portal, select Data Collection Rules > Create to open the DCR creation page.
The Basic page includes basic information about the DCR.
Setting |
Description |
Rule Name |
Name for the DCR. The name should be something descriptive that helps you identify the rule. |
Subscription |
Subscription to store the DCR. The subscription doesn't need to be the same subscription as the virtual machines. |
Resource group |
Resource group to store the DCR. The resource group doesn't need to be the same resource group as the virtual machines. |
Region |
Region to store the DCR. The region must be the same region as any Log Analytics workspace or Azure Monitor workspace used in a destination of the DCR. If you have workspaces in different regions, then create multiple DCRs associated with the same set of machines. |
Platform Type |
Specifies the type of data sources that will be available for the DCR, either Windows or Linux. None allows for both. 1 |
Data Collection Endpoint |
Specifies the data collection endpoint (DCE) used to collect data. The DCE is only required if you're using Azure Monitor Private Links. This DCE must be in the same region as the DCR. For more information, see How to set up data collection endpoints based on your deployment. |
1 This option sets the kind
attribute in the DCR. There are other values that can be set for this attribute, but they aren't available in the portal.
Add resources
The Resources page allows you to add resources to be associated with the DCR. Select + Add resources to select resources. The Azure Monitor agent will automatically be installed on any resources that don't already have it.
Important
The portal enables system-assigned managed identity on the target resources, along with existing user-assigned identities, if there are any. For existing applications, unless you specify the user-assigned identity in the request, the machine defaults to using system-assigned identity instead.
If the machine you're monitoring isn't in the same region as your destination Log Analytics workspace and you're collecting data types that require a DCE, select Enable Data Collection Endpoints and select an endpoint in the region of each monitored machine. If the monitored machine is in the same region as your destination Log Analytics workspace, or if you don't require a DCE, don't select a data collection endpoint on the Resources tab.
Add data sources
The Collect and deliver page allows you to add and configure data sources for the DCR and a destination for each.
Screen element |
Description |
Data source |
Select a Data source type and define related fields based on the data source type you select. See the articles in Data sources for details on configuring each type of data source. |
Destination |
Add one or more destinations for each data source. You can select multiple destinations of the same or different types. For instance, you can select multiple Log Analytics workspaces, which is also known as multihoming. See the details for each data type for the different destinations they support. |
A DCR can contain multiple different data sources up to a limit of 10 data sources in a single DCR. You can combine different data sources in the same DCR, but you will typically want to create different DCRs for different data collection scenarios. See Best practices for data collection rule creation and management in Azure Monitor for recommendations on how to organize your DCRs.
Note
It can take up to 5 minutes for data to be sent to the destinations when you create a data collection rule using the data collection rule wizard.
Create with CLI
Use the az monitor data-collection rule create command to create a DCR from your JSON file.
az monitor data-collection rule create --location 'eastus' --resource-group 'my-resource-group' --name 'my-dcr' --rule-file 'C:\MyNewDCR.json' --description 'This is my new DCR'
Use the az monitor data-collection rule association create command to create an association between your DCR and resource.
az monitor data-collection rule association create --name "my-vm-dcr-association" --rule-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.Insights/dataCollectionRules/my-dcr" --resource "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.Compute/virtualMachines/my-vm"
Create with PowerShell
Use the New-AzDataCollectionRule cmdlet to create a DCR from your JSON file.
New-AzDataCollectionRule -Name 'my-dcr' -ResourceGroupName 'my-resource-group' -JsonFilePath 'C:\MyNewDCR.json'
Use the New-AzDataCollectionRuleAssociation command to create an association between your DCR and resource.
New-AzDataCollectionRuleAssociation -TargetResourceId '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.Compute/virtualMachines/my-vm' -DataCollectionRuleId '/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/microsoft.insights/datacollectionrules/my-dcr' -AssociationName 'my-vm-dcr-association'
Create with API
Use the DCR create API to create the DCR from your JSON file. You can use any method to call a REST API as shown in the following examples.
$ResourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.Insights/dataCollectionRules/my-dcr"
$FilePath = ".\my-dcr.json"
$DCRContent = Get-Content $FilePath -Raw
Invoke-AzRestMethod -Path ("$ResourceId"+"?api-version=2022-06-01") -Method PUT -Payload $DCRContent
ResourceId="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.Insights/dataCollectionRules/my-dcr"
FilePath="my-dcr.json"
az rest --method put --url $ResourceId"?api-version=2022-06-01" --body @$FilePath
Create with ARM template
See the following references for defining DCRs and associations in a template.
DCR
Use the following template to create a DCR using information from Structure of a data collection rule in Azure Monitor and Sample data collection rules (DCRs) in Azure Monitor to define the dcr-properties
.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"dataCollectionRuleName": {
"type": "string",
"metadata": {
"description": "Specifies the name of the Data Collection Rule to create."
}
},
"location": {
"type": "string",
"metadata": {
"description": "Specifies the location in which to create the Data Collection Rule."
}
}
},
"resources": [
{
"type": "Microsoft.Insights/dataCollectionRules",
"name": "[parameters('dataCollectionRuleName')]",
"location": "[parameters('location')]",
"apiVersion": "2021-09-01-preview",
"properties": {
"<dcr-properties>"
}
}
]
}
DCR Association -Azure VM
The following sample creates an association between an Azure virtual machine and a data collection rule.
Bicep template file
@description('The name of the virtual machine.')
param vmName string
@description('The name of the association.')
param associationName string
@description('The resource ID of the data collection rule.')
param dataCollectionRuleId string
resource vm 'Microsoft.Compute/virtualMachines@2021-11-01' existing = {
name: vmName
}
resource association 'Microsoft.Insights/dataCollectionRuleAssociations@2021-09-01-preview' = {
name: associationName
scope: vm
properties: {
description: 'Association of data collection rule. Deleting this association will break the data collection for this virtual machine.'
dataCollectionRuleId: dataCollectionRuleId
}
}
ARM template file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string",
"metadata": {
"description": "The name of the virtual machine."
}
},
"associationName": {
"type": "string",
"metadata": {
"description": "The name of the association."
}
},
"dataCollectionRuleId": {
"type": "string",
"metadata": {
"description": "The resource ID of the data collection rule."
}
}
},
"resources": [
{
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"apiVersion": "2021-09-01-preview",
"scope": "[format('Microsoft.Compute/virtualMachines/{0}', parameters('vmName'))]",
"name": "[parameters('associationName')]",
"properties": {
"description": "Association of data collection rule. Deleting this association will break the data collection for this virtual machine.",
"dataCollectionRuleId": "[parameters('dataCollectionRuleId')]"
}
}
]
}
Parameter file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"value": "my-azure-vm"
},
"associationName": {
"value": "my-windows-vm-my-dcr"
},
"dataCollectionRuleId": {
"value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/microsoft.insights/datacollectionrules/my-dcr"
}
}
}
DCR Association -Arc-enabled server
The following sample creates an association between an Azure Arc-enabled server and a data collection rule.
Bicep template file
@description('The name of the virtual machine.')
param vmName string
@description('The name of the association.')
param associationName string
@description('The resource ID of the data collection rule.')
param dataCollectionRuleId string
resource vm 'Microsoft.HybridCompute/machines@2021-11-01' existing = {
name: vmName
}
resource association 'Microsoft.Insights/dataCollectionRuleAssociations@2021-09-01-preview' = {
name: associationName
scope: vm
properties: {
description: 'Association of data collection rule. Deleting this association will break the data collection for this Arc server.'
dataCollectionRuleId: dataCollectionRuleId
}
}
ARM template file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string",
"metadata": {
"description": "The name of the virtual machine."
}
},
"associationName": {
"type": "string",
"metadata": {
"description": "The name of the association."
}
},
"dataCollectionRuleId": {
"type": "string",
"metadata": {
"description": "The resource ID of the data collection rule."
}
}
},
"resources": [
{
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"apiVersion": "2021-09-01-preview",
"scope": "[format('Microsoft.HybridCompute/machines/{0}', parameters('vmName'))]",
"name": "[parameters('associationName')]",
"properties": {
"description": "Association of data collection rule. Deleting this association will break the data collection for this Arc server.",
"dataCollectionRuleId": "[parameters('dataCollectionRuleId')]"
}
}
]
}
Parameter file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"value": "my-hybrid-vm"
},
"associationName": {
"value": "my-windows-vm-my-dcr"
},
"dataCollectionRuleId": {
"value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/microsoft.insights/datacollectionrules/my-dcr"
}
}
}
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.
To create a data collection rule for metrics export use the Azure portal, Azure CLI, PowerShell, API, or ARM templates.
On the Monitor menu in the Azure portal, select Data Collection Rules then select Create.
To create a DCR to collect platform metrics data, select the link on the top of the page.
On the Create Data Collection Rule page, enter a rule name, select a Subscription, Resource group, and Region for the DCR.
Select Enable Managed Identity if you want to send metrics to a Storage Account or Event Hubs.
Select Next
On the Resources page, select Add resources to add the resources you want to collect metrics from.
Select Next to move to the Collect and deliver tab.
Select Add new dataflow
The resource type of the resource that chose in the previous step is automatically selected. Add more resource types if you want to use this rule to collect metrics from multiple resource types in the future.
Select Next Destinations to move to the Destinations tab.
To send metrics to a Log Analytics workspace, select Azure Monitor Logs from the Destination type dropdown.
- Select the Subscription and the Log Analytics workspace you want to send the metrics to.
To send metrics to Event Hubs, select Event Hub from the Destination type dropdown.
- Select the Subscription, the Event Hub namespace, and the Event Hub instance name.
To send metrics to a Storage Account, select Storage Account from the Destination type dropdown.
- Select the Subscription, the Storage Account, and the Blob container where you want to store the metrics.
Note
To sent metrics to a Storage Account or Event Hubs, the resource generating the metrics, the DCR, and the Storage Account or Event Hub, must all be in the same region.
To send metrics to a Log Analytics workspace, the DCR must be in the same region as the Log Analytics workspace. The resource generating the metrics can be in any region.
To select Storage Account or Event Hubs as the destination, you must enable managed identity for the DCR on the Basics tab.
Select Save , then select Review + create.
Create a JSON file containing the collection rule specification. For more information, see DCR specifications. For sample JSON files, see Sample Metrics Export JSON objects.
Important
The rule file has the same format as used for PowerShell and the REST API, however the file must not contain identity
, the location
, or kind
. These parameters are specified in the az monitor data-collection rule create
command.
Use the following command to create a data collection rule for metrics using the Azure CLI.
az monitor data-collection rule create
--name
--resource-group
--location
--kind PlatformTelemetry
--rule-file
[--identity "{type:'SystemAssigned'}" ]
For storage account and Event Hubs destinations, you must enable managed identity for the DCR using --identity "{type:'SystemAssigned'}"
. Identity isn't required for Log Analytics workspaces.
For example,
az monitor data-collection rule create
--name cli-dcr-001
--resource-group rg-001
--location centralus
--kind PlatformTelemetry
--identity "{type:'SystemAssigned'}"
--rule-file cli-dcr.json
Copy the id
and the principalId
of the DCR to use in assigning the role to create an association between the DCR and a resource.
"id": "/subscriptions/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f/resourceGroups/rg-001/providers/Microsoft.Insights/dataCollectionRules/cli-dcr-001",
"identity": {
"principalId": "eeeeeeee-ffff-aaaa-5555-666666666666",
"tenantId": "0000aaaa-11bb-cccc-dd22-eeeeee333333",
"type": "systemAssigned"
},
Grant write permissions to the managed entity
The managed identity used by the DCR must have write permissions to the destination when the destination is a Storage Account or Event Hubs.
To grant permissions for the rule's managed entity, assign the appropriate role to the entity.
The following table shows the roles required for each destination type:
Destination type |
Role |
Log Analytics workspace |
not required |
Azure storage account |
Storage Blob Data Contributor |
Event Hubs |
Azure Event Hubs Data Sender |
For more information on assigning roles, see Assign Azure roles to a managed identity.
To assign a role to a managed identity using CLI, use az role assignment create
. For more information, see Role Assignments - Create
Assign the appropriate role to the managed identity of the DCR.
az role assignment create --assignee <system assigned principal ID> \
--role <`Storage Blob Data Contributor` or `Azure Event Hubs Data Sender` \
--scope <storage account ID or eventhub ID>
The following example assigns the Storage Blob Data Contributor
role to the managed identity of the DCR for a storage account.
az role assignment create --assignee eeeeeeee-ffff-aaaa-5555-666666666666 \
--role "Storage Blob Data Contributor" \
--scope /subscriptions/bbbb1b1b-cc2c-DD3D-ee4e-ffffff5f5f5f/resourceGroups/ed-rg-DCRTest/providers/Microsoft.Storage/storageAccounts/metricsexport001
Create a data collection rule association
After you create the data collection rule, create a data collection rule association (DCRA) to associate the rule with the resource to be monitored. For more information, see Data Collection Rule Associations - Create
Use az monitor data-collection rule association create
to create an association between a data collection rule and a resource.
az monitor data-collection rule association create --name
--rule-id
--resource
The following example creates an association between a data collection rule and a Key Vault.
az monitor data-collection rule association create --name "keyValut-001" \
--rule-id "/subscriptions/bbbb1b1b-cc2c-DD3D-ee4e-ffffff5f5f5f/resourceGroups/rg-dcr/providers/Microsoft.Insights/dataCollectionRules/dcr-cli-001" \
--resource "/subscriptions/bbbb1b1b-cc2c-DD3D-ee4e-ffffff5f5f5f/resourceGroups/rg-dcr/providers/Microsoft.KeyVault/vaults/keyVault-001"
Create a JSON file containing the collection rule specification. For more information, see DCR specifications. For sample JSON files, see Sample Metrics Export JSON objects.
Use the New-AzDataCollectionRule
command to create a data collection rule for metrics using PowerShell. For more information, see New-AzDataCollectionRule.
New-AzDataCollectionRule -Name
-ResourceGroupName
-JsonFilePath
For example,
New-AzDataCollectionRule -Name dcr-powershell-hub -ResourceGroupName rg-001 -JsonFilePath dcr-storage-account.json
Copy the id
and the IdentityPrincipalId
of the DCR to use in assigning the role to create an association between the DCR and a resource.resource.
Id : /subscriptions/bbbb1b1b-cc2c-DD3D-ee4e-ffffff5f5f5f/resourceGroups/rg-001/providers/Microsoft.Insights/dataCollectionRules/dcr-powershell-hub
IdentityPrincipalId : eeeeeeee-ffff-aaaa-5555-666666666666
IdentityTenantId : 0000aaaa-11bb-cccc-dd22-eeeeee333333
IdentityType : systemAssigned
IdentityUserAssignedIdentity : {
}
Grant write permissions to the managed entity
The managed identity used by the DCR must have write permissions to the destination when the destination is a Storage Account or Event Hubs.
To grant permissions for the rule's managed entity, assign the appropriate role to the entity.
The following table shows the roles required for each destination type:
Destination type |
Role |
Log Analytics workspace |
not required |
Azure storage account |
Storage Blob Data Contributor |
Event Hubs |
Azure Event Hubs Data Sender |
For more information, see Assign Azure roles to a managed identity.
To assign a role to a managed identity using PowerShell, see New-AzRoleAssignment
Assign the appropriate role to the managed identity of the DCR using New-AzRoleAssignment
.
New-AzRoleAssignment -ObjectId <objectId> -RoleDefinitionName <roleName> -Scope /subscriptions/<subscriptionId>/resourcegroups/<resourceGroupName>/providers/<providerName>/<resourceType>/<resourceSubType>/<resourceName>
The following example assigns the Azure Event Hubs Data Sender
role to the managed identity of the DCR at the subscription level.
New-AzRoleAssignment -ObjectId eeeeeeee-ffff-aaaa-5555-666666666666 -RoleDefinitionName "Azure Event Hubs Data Sender" -Scope /subscriptions/bbbb1b1b-cc2c-DD3D-ee4e-ffffff5f5f5f
Create a data collection rule association
After you create the data collection rule, create a data collection rule association (DCRA) to associate the rule with the resource to be monitored. Use New-AzDataCollectionRuleAssociation
to create an association between a data collection rule and a resource. For more information, see New-AzDataCollectionRuleAssociation
New-AzDataCollectionRuleAssociation
-AssociationName <String>
-ResourceUri <String>
-DataCollectionRuleId <String>
The following example creates an association between a data collection rule and a Key Vault.
New-AzDataCollectionRuleAssociation
-AssociationName keyVault-001-association
-ResourceUri /subscriptions/bbbb1b1b-cc2c-DD3D-ee4e-ffffff5f5f5f/resourceGroups/rg-dcr/providers/Microsoft.KeyVault/vaults/keyVault-001
-DataCollectionRuleId /subscriptions/bbbb1b1b-cc2c-DD3D-ee4e-ffffff5f5f5f/resourceGroups/rg-dcr/providers/Microsoft.Insights/dataCollectionRules/vaultsDCR001
Create a data collection rule using the REST API
Creating a data collection rule for metrics requires the following steps:
- Create the data collection rule.
- Grant permissions for the rule's managed entity to write to the destination
- Create a data collection rule association.
Create the data collection rule
To create a DCR using the REST API, you must make an authenticated request using a bearer token. For more information on authenticating with Azure Monitor, see Authenticate Azure Monitor requests.
Use the following endpoint to create a data collection rule for metrics using the REST API.
For more information, see Data Collection Rules - Create.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}?api-version=2023-03-11
For example
https://management.azure.com/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/rg-001/providers/Microsoft.Insights/dataCollectionRules/dcr-001?api-version=2023-03-11
The payload is a JSON object that defines a collection rule. The payload is sent in the body of the request. For more information on the JSON structure, see DCR specifications. For sample DCR JSON objects, see Sample Metrics Export JSON objects
Grant write permissions to the managed entity
The managed identity used by the DCR must have write permissions to the destination when the destination is a Storage Account or Event Hubs.
To grant permissions for the rule's managed entity, assign the appropriate role to the entity.
The following table shows the roles required for each destination type:
Destination type |
Role |
Log Analytics workspace |
not required |
Azure storage account |
Storage Blob Data Contributor |
Event Hubs |
Azure Event Hubs Data Sender |
For more information, see Assign Azure roles to a managed identity.
To assign a role to a managed identity using REST, see Role Assignments - Create
Create a data collection rule association
After you create the data collection rule, create a data collection rule association (DCRA) to associate the rule with the resource to be monitored. For more information, see Data Collection Rule Associations - Create
To create a DCRA using the REST API, use the following endpoint and payload:
PUT https://management.azure.com/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}?api-version=2022-06-0
Body:
{
"properties":
{
"description": "<DCRA description>",
"dataCollectionRuleId": "/subscriptions/{subscriptionId}/resourceGroups/{resource group name}/providers/Microsoft.Insights/dataCollectionRules/{DCR name}"
}
}
For example,
https://management.azure.com//subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/rg-001/providers/Microsoft.Compute/virtualMachines/vm002/providers/Microsoft.Insights/dataCollectionRuleAssociations/dcr-la-ws-vm002?api-version=2023-03-11
{
"properties":
{
"description": "Association of platform telemetry DCR with VM vm002",
"dataCollectionRuleId": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/rg-001/providers/Microsoft.Insights/dataCollectionRules/dcr-la-ws"
}
}
Use the following template to create a DCR. For more information, see Microsoft.Insights dataCollectionRules
Template file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"dataCollectionRuleName": {
"type": "string",
"metadata": {
"description": "Specifies the name of the Data Collection Rule to create."
}
},
"location": {
"type": "string",
"metadata": {
"description": "Specifies the location in which to create the Data Collection Rule."
}
}
},
"resources": [
{
"type": "Microsoft.Insights/dataCollectionRules",
"name": "[parameters('dataCollectionRuleName')]",
"kind": "PlatformTelemetry",
"identity": {
"type": "userassigned" | "systemAssigned",
"userAssignedIdentities": {
"type": "string"
}
},
"location": "[parameters('location')]",
"apiVersion": "2023-03-11",
"properties": {
"dataSources": {
"platformTelemetry": [
{
"streams": [
"<resourcetype>:<metric name> | Metrics-Group-All"
],
"name": "myPlatformTelemetryDataSource"
}
]
},
"destinations": {
"logAnalytics": [
{
"workspaceResourceId": "[parameters('workspaceId')]",
"name": "myDestination"
}
]
},
"dataFlows": [
{
"streams": [
"<resourcetype>:<metric name> | Metrics-Group-All"
],
"destinations": [
"myDestination"
]
}
]
}
}
]
}
Parameters file
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"dataCollectionRuleName": {
"value": "metrics-dcr-001"
},
"workspaceId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/azuremonitorworkspaceinsights/providers/microsoft.operationalinsights/workspaces/amw-insight-ws"
},
"location": {
"value": "eastus"
}
}
}
Sample DCR template:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Insights/dataCollectionRules",
"apiVersion": "2023-03-11",
"name": "[parameters('dataCollectionRuleName')]",
"location": "[parameters('location')]",
"kind": "PlatformTelemetry",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"dataSources": {
"platformTelemetry": [
{
"streams": [
"Microsoft.Compute/virtualMachines:Metrics-Group-All",
"Microsoft.Compute/virtualMachineScaleSets:Metrics-Group-All",
"Microsoft.Cache/redis:Metrics-Group-All",
"Microsoft.keyvault/vaults:Metrics-Group-All"
],
"name": "myPlatformTelemetryDataSource"
}
]
},
"destinations": {
"logAnalytics": [
{
"workspaceResourceId": "[parameters('workspaceId')]",
"name": "myDestination"
}
]
},
"dataFlows": [
{
"streams": [
"Microsoft.Compute/virtualMachines:Metrics-Group-All",
"Microsoft.Compute/virtualMachineScaleSets:Metrics-Group-All",
"Microsoft.Cache/redis:Metrics-Group-All",
"Microsoft.keyvault/vaults:Metrics-Group-All"
],
"destinations": [
"myDestination"
]
}
]
}
}
]
}
After creating the DCR and DCRA, allow up to 30 minutes for the first platform metrics data to appear in the Log Analytics Workspace. Once data starts flowing, the latency for a platform metric time series flowing to a Log Analytics workspace, Storage Account, or Event Hubs is approximately 3 minutes, depending on the resource type.