I’m trying to set up an Azure Monitor Metric Alert for pipeline failures in Azure Data Factory using PowerShell, but I'm getting conflicting errors.
$condition = New-AzMetricAlertRuleV2Criteria -MetricName "PipelineFailedRuns" -MetricNameSpace "Microsoft.DataFactory/factories" -TimeAggregation Total -Operator GreaterThan -Threshold 0
Add-AzMetricAlertRuleV2 -Name $alertRuleName -ResourceGroupName $resourceGroup -Description "Alert for failed pipeline runs in" -WindowSize $windowSize -Frequency $frequency -TargetResourceId $targetResourceId -Condition $condition -ActionGroup $actionGroupId -Severity 4
Error: "MetricNamespace must be Microsoft.DataFactory/factories/pipelines"
Updated as per error message:
$condition = New-AzMetricAlertRuleV2Criteria -MetricName "PipelineFailedRuns" -MetricNameSpace "Microsoft.DataFactory/factories/pipelines" -TimeAggregation Total -Operator GreaterThan -Threshold 0
Error: "Microsoft.DataFactory/factories/pipelines is not a supported metric namespace" "
This is the document I have referenced, it says "Microsoft.DataFactory/factories" is the namespace for the metric "PipelineFailedRuns"
I’m trying to set up an Azure Monitor Metric Alert for pipeline failures in Azure Data Factory using PowerShell, but I'm getting conflicting errors.
$condition = New-AzMetricAlertRuleV2Criteria -MetricName "PipelineFailedRuns" -MetricNameSpace "Microsoft.DataFactory/factories" -TimeAggregation Total -Operator GreaterThan -Threshold 0
Add-AzMetricAlertRuleV2 -Name $alertRuleName -ResourceGroupName $resourceGroup -Description "Alert for failed pipeline runs in" -WindowSize $windowSize -Frequency $frequency -TargetResourceId $targetResourceId -Condition $condition -ActionGroup $actionGroupId -Severity 4
Error: "MetricNamespace must be Microsoft.DataFactory/factories/pipelines"
Updated as per error message:
$condition = New-AzMetricAlertRuleV2Criteria -MetricName "PipelineFailedRuns" -MetricNameSpace "Microsoft.DataFactory/factories/pipelines" -TimeAggregation Total -Operator GreaterThan -Threshold 0
Error: "Microsoft.DataFactory/factories/pipelines is not a supported metric namespace" "
This is the document I have referenced, it says "Microsoft.DataFactory/factories" is the namespace for the metric "PipelineFailedRuns"
Share Improve this question edited Feb 14 at 8:52 Jyothi asked Feb 14 at 6:47 JyothiJyothi 1091 gold badge2 silver badges13 bronze badges 5- Haven't you tried ADF alerts? – Rakesh Govindula Commented Feb 14 at 7:03
- Can you provide the alert condition details and all clearly. @Jyothi – Jahnavi Commented Feb 14 at 8:04
- 1 @Jahnavi i have added the condition information above and here it is $condition = New-AzMetricAlertRuleV2Criteria -MetricName "PipeLineFailedRuns" -MetricNameSpace "Microsoft.DataFactory/factories" -TimeAggregation Total -Operator GreaterThan -Threshold 0 any more details required – Jyothi Commented Feb 14 at 8:32
- @RakeshGovindula, I manually tested alerts in 'Alerts & Metrics' in ADF and was able to create them successfully. However, I’d like to automate this using PowerShell since there are many pipelines that need individual alerts configured. – Jyothi Commented Feb 14 at 8:35
- Updated the answer. @Jyothi – Jahnavi Commented Feb 14 at 9:43
1 Answer
Reset to default 0Use below PowerShell commands to add a metric alert set up rule for data factories.
$condition = New-AzMetricAlertRuleV2Criteria -MetricName "PipelineFailedRuns" -MetricNameSpace "Microsoft.DataFactory/factories" -TimeAggregation Total -Operator GreaterThan -Threshold 0
$alertRuleName = "newalertsam"
$resourceGroup = "LogAnalyticsDefaultResources"
$targetResourceId="/subscriptions/xxxx/resourceGroups/LogAnalyticsDefaultResources/providers/Microsoft.DataFactory/factories/samplepowdf"
$actionGroupId = "/subscriptions/xxxx/resourceGroups/LogAnalyticsDefaultResources/providers/microsoft.insights/actiongroups/newact"
Add-AzMetricAlertRuleV2 -Name $alertRuleName -ResourceGroupName $resourceGroup -Description "Alert for failed pipeline runs in" -WindowSize 00:05:00 -Frequency 00:05:00 -TargetResourceId $targetResourceId -Condition $condition -ActionGroupId $actionGroupId -Severity 4
Reference MS Doc for PowerShell command:
Add-azmetricalertrulev2