Reputation: 109
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"
Upvotes: 0
Views: 52
Reputation: 8008
Use 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
Upvotes: 0