New-AzDataCollectionRule
Create a data collection rule.
Syntax
New-AzDataCollectionRule
-Location <String>
-ResourceGroupName <String>
-RuleName <String>
-RuleFile <String>
[-Description <String>]
[-Tag <Hashtable>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The New-AzDataCollectionRule cmdlet creates a data collection rule.
Data Collection Rules (DCR) define data coming into Azure Monitor and specify where that data should be sent or stored. Here is the complete DCR overview article.
To use the -RuleFile parameter, construct a json file containing three properties: dataSources, destinations, dataFlows (see Example #1)
You may find here the schema detail.
The output of a DCR serialized with the cmdlet ConvertTo-Json is also supported (see Example #2).
Examples
Example 1: Create data collection rule, JSON from Rest API
New-AzDataCollectionRule -Location 'East US 2 EUAP' -ResourceGroupName 'testdcr' `
-RuleName 'newDcrEx1' -RuleFile 'C:\samples\dcrEx1.json' `
-Description 'Dcr description' `
-Tag @{"tag1"="value1"; "tag2"="value2"}
Description : Dcr description
DataSources : Microsoft.Azure.Commands.Insights.OutputClasses.PSDataCollectionRuleDataSources
Destinations : Microsoft.Azure.Commands.Insights.OutputClasses.PSDataCollectionRuleDestinations
DataFlows : {Microsoft.Azure.Commands.Insights.OutputClasses.PSDataFlow}
ProvisioningState : Succeeded
Etag : "{etag}"
Id : /subscriptions/{subId}/resourceGroups/testdcr/providers/Microsoft.Insights/dataCollectionRules/newDcrEx1
Name : newDcrEx1
Type : Microsoft.Insights/dataCollectionRules
Location : East US 2 EUAP
Tags : {[tag2, value2], [tag1, value1]}
# Note: Content of C:\samples\dcrEx1.json
{
"properties": {
"dataSources": {
"performanceCounters": [
{
"streams": [
"Microsoft-InsightsMetrics"
],
"scheduledTransferPeriod": "PT1M",
"samplingFrequencyInSeconds": 10,
"counterSpecifiers": [
"\\Processor Information(_Total)\\% Processor Time"
],
"name": "perfCounter01"
}
]
},
"destinations": {
"azureMonitorMetrics": {
"name": "azureMonitorMetrics-default"
}
},
"dataFlows": [
{
"streams": [
"Microsoft-InsightsMetrics"
],
"destinations": [
"azureMonitorMetrics-default"
]
}
]
}
}
This command creates a data collection rules for the current subscription.
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Description
The resource description
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Location
The resource location
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ResourceGroupName
The resource group name
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RuleFile
The JSON file path
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RuleName
The resource name
Type: | String |
Aliases: | Name |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Tag
The resource tags
Type: | Hashtable |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Outputs
Related Links
Feedback
Submit and view feedback for