You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/alerts/alerts-create-rule-cli-powershell-arm.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: This article shows you how to create a new alert rule using the CLI
4
4
author: AbbyMSFT
5
5
ms.author: abbyweisberg
6
6
ms.topic: how-to
7
-
ms.date: 11/29/2023
7
+
ms.date: 01/03/2024
8
8
ms.reviewer: harelbr
9
9
---
10
10
# Create a new alert rule using the CLI, PowerShell, or an ARM template
@@ -14,14 +14,17 @@ You can create a new alert rule using the [the CLI](#create-a-new-alert-rule-usi
14
14
15
15
You can create a new alert rule using the [Azure CLI](/cli/azure/get-started-with-azure-cli). The following code examples use [Azure Cloud Shell](../../cloud-shell/overview.md). You can see the full list of the [Azure CLI commands for Azure Monitor](/cli/azure/azure-cli-reference-for-monitor#azure-monitor-references).
16
16
17
-
1. In the [portal](https://portal.azure.com/), select **Cloud Shell**. At the prompt, use the commands that follow.
17
+
1. In the [portal](https://portal.azure.com/), select **Cloud Shell**. At the prompt, use these.
18
18
19
-
To create a metric alert rule, use the `az monitor metrics alert create` command. You can see detailed documentation on the metric alert rule create command in the `az monitor metrics alert create` section of the [CLI reference documentation for metric alerts](/cli/azure/monitor/metrics/alert).
19
+
- To create a metric alert rule, use the [az monitor metrics alert create](/cli/azure/monitor/metrics/alert) command.
20
+
- To create a log alert rule, use the [az monitor scheduled-query create](/cli/azure/monitor/scheduled-query) command.
21
+
- To create an activity log alert rule, use the [az monitor activity-log alert create](/cli/azure/monitor/activity-log/alert) command.
20
22
21
-
To create a metric alert rule that monitors if average Percentage CPU on a VM is greater than 90:
23
+
For example, to create a metric alert rule that monitors if average Percentage CPU on a VM is greater than 90:
22
24
```azurecli
23
25
az monitor metrics alert create -n {nameofthealert} -g {ResourceGroup} --scopes {VirtualMachineResourceID} --condition "avg Percentage CPU > 90" --description {descriptionofthealert}
24
26
```
27
+
25
28
## Create a new alert rule using PowerShell
26
29
27
30
- To create a metric alert rule using PowerShell, use the [Add-AzMetricAlertRuleV2](/powershell/module/az.monitor/add-azmetricalertrulev2) cmdlet.
@@ -43,6 +46,7 @@ You can use an [Azure Resource Manager template (ARM template)](../../azure-reso
43
46
- For metric alerts: [Resource Manager template samples for metric alert rules](resource-manager-alerts-metric.md)
44
47
- For log alerts: [Resource Manager template samples for log alert rules](resource-manager-alerts-log.md)
45
48
- For activity log alerts: [Resource Manager template samples for activity log alert rules](resource-manager-alerts-activity-log.md)
49
+
- For service health alerts: [Resource Manager template samples for service health alert rules](resource-manager-alerts-service-health.md)
46
50
- For resource health alerts: [Resource Manager template samples for resource health alert rules](resource-manager-alerts-resource-health.md)
47
51
1. Edit the template file to contain appropriate information for your alert, and save the file as \<your-alert-template-file\>.json.
48
52
1. Edit the corresponding parameters file to customize the alert, and save as \<your-alert-template-file\>.parameters.json.
0 commit comments