Skip to content

Commit bea9fd0

Browse files
Merge pull request #263948 from AbbyMSFT/metric-alerts-support-issue
Clarification about creating metric alerts programatically
2 parents f288a53 + 49f26f6 commit bea9fd0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

articles/azure-monitor/alerts/alerts-create-rule-cli-powershell-arm.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ You can create a new alert rule using the [Azure CLI](/cli/azure/get-started-wit
2929
## Create a new alert rule using PowerShell
3030
3131
- To create a metric alert rule using PowerShell, use the [Add-AzMetricAlertRuleV2](/powershell/module/az.monitor/add-azmetricalertrulev2) cmdlet.
32+
> [!NOTE]
33+
> When you create a metric alert on a single resource, the syntax uses the `TargetResourceId`. When you create a metric alert on multiple resources, the syntax contains the `TargetResourceScope`, `TargetResourceType`, and `TargetResourceRegion`.
3234
- To create a log alert rule using PowerShell, use the [New-AzScheduledQueryRule](/powershell/module/az.monitor/new-azscheduledqueryrule) cmdlet.
3335
- To create an activity log alert rule using PowerShell, use the [Set-AzActivityLogAlert](/powershell/module/az.monitor/set-azactivitylogalert) cmdlet.
3436
@@ -38,11 +40,13 @@ You can use an [Azure Resource Manager template (ARM template)](../../azure-reso
3840
3941
1. Create a new resource, using the following resource types:
4042
- For metric alerts: `Microsoft.Insights/metricAlerts`
43+
> [!NOTE]
44+
> - We recommend that you create the metric alert using the same resource group as your target resource.
45+
> - Metric alerts for an Azure Log Analytics workspace resource type (`Microsoft.OperationalInsights/workspaces`) are configured differently than other metric alerts. For more information, see [Resource Template for Metric Alerts for Logs](alerts-metric-logs.md#resource-template-for-metric-alerts-for-logs).
46+
> - If you are creating a metric alert for a single resource, the template uses the `ResourceId` of the target resource. If you are creating a metric alert for multiple resources, the template uses the `scope`, `TargetResourceType`, and `TargetResourceRegion` for the target resources.
4147
- For log alerts: `Microsoft.Insights/scheduledQueryRules`
4248
- For activity log, service health, and resource health alerts: `microsoft.Insights/activityLogAlerts`
43-
> [!NOTE]
44-
> - Metric alerts for an Azure Log Analytics workspace resource type (`Microsoft.OperationalInsights/workspaces`) are configured differently than other metric alerts. For more information, see [Resource Template for Metric Alerts for Logs](alerts-metric-logs.md#resource-template-for-metric-alerts-for-logs).
45-
> - We recommend that you create the metric alert using the same resource group as your target resource.
49+
4650
1. Copy one of the templates from these sample ARM templates.
4751
- For metric alerts: [Resource Manager template samples for metric alert rules](resource-manager-alerts-metric.md)
4852
- For log alerts: [Resource Manager template samples for log alert rules](resource-manager-alerts-log.md)

articles/azure-monitor/alerts/resource-manager-alerts-metric.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,8 @@ This section will describe Azure Resource Manager templates for three scenarios
19701970

19711971
> [!NOTE]
19721972
>
1973-
> In a metric alert rule that monitors multiple resources, only one condition is allowed.
1973+
> - In a metric alert rule that monitors multiple resources, only one condition is allowed.
1974+
> - If you are creating a metric alert for a single resource, the template uses the `ResourceId` of the target resource. If you are creating a metric alert for multiple resources, the template uses the `scope`, `TargetResourceType`, and `TargetResourceRegion` for the target resources.
19741975
19751976
### Static threshold alert on all virtual machines in one or more resource groups
19761977

0 commit comments

Comments
 (0)