Skip to content

Commit 6007c5e

Browse files
authored
Merge pull request #179341 from AbbyMSFT/new-alert-ui
New UI to create alert rules
2 parents 2329252 + 469f5ae commit 6007c5e

20 files changed

+198
-258
lines changed

articles/azure-monitor/alerts/alerts-log-api-switch.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ In the past, users used the [legacy Log Analytics Alert API](./api-alerts.md) to
2121
- Single template for creation of alert rules (previously needed three separate templates).
2222
- Single API for all Azure resources log alerting.
2323
- Support for stateful and 1-minute log alert previews.
24-
- [PowerShell cmdlets support](./alerts-log.md#managing-log-alerts-using-powershell).
24+
- [PowerShell cmdlets support](./alerts-manage-alerts-previous-version.md#manage-log-alerts-using-powershell).
2525
- Alignment of severities with all other alert types.
2626
- Ability to create [cross workspace log alert](../logs/cross-workspace-query.md) that span several external resources like Log Analytics workspaces or Application Insights resources.
2727
- Users can specify dimensions to split the alerts.
2828
- Log alerts have extended period of up to two days of data (previously limited to one day).
2929

3030
## Impact
3131

32-
- All new rules must be created/edited with the current API. See [sample use via Azure Resource Template](alerts-log-create-templates.md) and [sample use via PowerShell](./alerts-log.md#managing-log-alerts-using-powershell).
32+
- All new rules must be created/edited with the current API. See [sample use via Azure Resource Template](alerts-log-create-templates.md) and [sample use via PowerShell](./alerts-manage-alerts-previous-version.md#manage-log-alerts-using-powershell).
3333
- As rules become Azure Resource Manager tracked resources in the current API and must be unique, rules resource ID will change to this structure: `<WorkspaceName>|<savedSearchId>|<scheduleId>|<ActionId>`. Display names of the alert rule will remain unchanged.
3434

3535
## Process
@@ -100,5 +100,5 @@ If the Log Analytics workspace wasn't switched, the response is:
100100

101101
- Learn about the [Azure Monitor - Log Alerts](./alerts-unified-log.md).
102102
- Learn how to [manage your log alerts using the API](alerts-log-create-templates.md).
103-
- Learn how to [manage log alerts using PowerShell](./alerts-log.md#managing-log-alerts-using-powershell).
104-
- Learn more about the [Azure Alerts experience](./alerts-overview.md).
103+
- Learn how to [manage log alerts using PowerShell](./alerts-manage-alerts-previous-version.md#manage-log-alerts-using-powershell).
104+
- Learn more about the [Azure Alerts experience](./alerts-overview.md).

articles/azure-monitor/alerts/alerts-log-query.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This article describes how to write and convert [Log Alert](./alerts-unified-log
1111

1212
## How to start writing an alert log query
1313

14-
Alert queries start from [querying the log data in Log Analytics](alerts-log.md#create-a-log-alert-rule-with-the-azure-portal) that indicates the issue. You can use the [alert query examples topic](../logs/queries.md) to understand what you can discover. You may also [get started on writing your own query](../logs/log-analytics-tutorial.md).
14+
Alert queries start from [querying the log data in Log Analytics](alerts-log.md#create-a-log-alert-rule-in-the-azure-portal) that indicates the issue. You can use the [alert query examples topic](../logs/queries.md) to understand what you can discover. You may also [get started on writing your own query](../logs/log-analytics-tutorial.md).
1515

1616
### Queries that indicate the issue and not the alert
1717

articles/azure-monitor/alerts/alerts-log.md

Lines changed: 69 additions & 252 deletions
Large diffs are not rendered by default.
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
title: View and manage log alert rules created in previous versions| Microsoft Docs
3+
description: Use the Azure Monitor portal to manage log alert rules created in earlier versions
4+
ms.author: abbyweisberg
5+
ms.topic: conceptual
6+
ms.date: 12/14/2021
7+
ms.custom: devx-track-azurepowershell, devx-track-azurecli
8+
---
9+
# Manage alert rules created in previous versions
10+
11+
> [!NOTE]
12+
> This article describes the process of managing alert rules created in the previous UI or using API version `2018-04-16` or earlier. Alert rules created in the latest UI are viewed and managed in the new UI, as described in [Create, view, and manage log alerts using Azure Monitor](alerts-log.md).
13+
14+
1. In the [portal](https://portal.azure.com/), select the relevant resource.
15+
1. Under **Monitoring**, select **Alerts**.
16+
1. From the top command bar, select **Alert rules**.
17+
1. Select the alert rule that you want to edit.
18+
1. In the **Condition** section, select the condition.
19+
1. The **Configure signal logic** pane opens, with historical data for the query appearing as a graph. You can change the time period of the chart to display data from the last six hours to last week.
20+
If your query results contain summarized data or specific columns without time column, the chart shows a single value.
21+
22+
:::image type="content" source="media/alerts-log/alerts-edit-alerts-rule.png" alt-text="Edit alerts rule.":::
23+
24+
1. Edit the alert rule conditions using these sections:
25+
- **Search Query**. In this section, you can modify your query.
26+
- **Alert logic**. Log Alerts can be based on two types of [**Measures**](./alerts-unified-log.md#measure):
27+
1. **Number of results** - Count of records returned by the query.
28+
1. **Metric measurement** - *Aggregate value* calculated using summarize grouped by the expressions chosen and the [bin()](/azure/data-explorer/kusto/query/binfunction) selection. For example:
29+
```Kusto
30+
// Reported errors
31+
union Event, Syslog // Event table stores Windows event records, Syslog stores Linux records
32+
| where EventLevelName == "Error" // EventLevelName is used in the Event (Windows) records
33+
or SeverityLevel== "err" // SeverityLevel is used in Syslog (Linux) records
34+
| summarize AggregatedValue = count() by Computer, bin(TimeGenerated, 15m)
35+
```
36+
For metric measurements alert logic, you can specify how to [split the alerts by dimensions](./alerts-unified-log.md#split-by-alert-dimensions) using the **Aggregate on** option. The row grouping expression must be unique and sorted.
37+
> [!NOTE]
38+
> Since the [bin()](/azure/data-explorer/kusto/query/binfunction) can result in uneven time intervals, the alert service will automatically convert the [bin()](/azure/data-explorer/kusto/query/binfunction) function to a [binat()](/azure/data-explorer/kusto/query/binatfunction) function with appropriate time at runtime, to ensure results with a fixed point.
39+
> [!NOTE]
40+
> Split by alert dimensions is only available for the current scheduledQueryRules API. If you use the legacy [Log Analytics Alert API](./api-alerts.md), you will need to switch. [Learn more about switching](./alerts-log-api-switch.md). Resource centric alerting at scale is only supported in the API version `2020-08-01` and above.
41+
42+
:::image type="content" source="media/alerts-log/aggregate-on.png" alt-text="Aggregate on.":::
43+
44+
- **Period**. Choose the time range over which to assess the specified condition, using [**Period**](./alerts-unified-log.md#query-time-range) option.
45+
46+
1. When you are finished editing the conditions, select **Done**.
47+
1. Using the preview data, set the [**Operator**, **Threshold Value**](./alerts-unified-log.md#threshold-and-operator), and [**Frequency**](./alerts-unified-log.md#frequency).
48+
1. Set the [number of violations to trigger an alert](./alerts-unified-log.md#number-of-violations-to-trigger-alert) by using **Total or Consecutive Breaches**.
49+
1. Select **Done**.
50+
1. You can edit the rule **Description**, and **Severity**. These details are used in all alert actions. Additionally, you can choose to not activate the alert rule on creation by selecting **Enable rule upon creation**.
51+
1. Use the [**Suppress Alerts**](./alerts-unified-log.md#state-and-resolving-alerts) option if you want to suppress rule actions for a specified time after an alert is fired. The rule will still run and create alerts but actions won't be triggered to prevent noise. Mute actions value must be greater than the frequency of alert to be effective.
52+
53+
![Suppress Alerts for Log Alerts](media/alerts-log/AlertsPreviewSuppress.png)
54+
1. Specify if the alert rule should trigger one or more [**Action Groups**](./action-groups.md#webhook) when alert condition is met.
55+
> [!NOTE]
56+
> Refer to the [Azure subscription service limits](../../azure-resource-manager/management/azure-subscription-service-limits.md) for limits on the actions that can be performed.
57+
> [!NOTE]
58+
> Log alert rules are currently [stateless and do not resolve](./alerts-unified-log.md#state-and-resolving-alerts).
59+
1. (Optional) Customize actions in log alert rules:
60+
- **Custom Email Subject**: Overrides the *e-mail subject* of email actions. You can't modify the body of the mail and this field **isn't for email addresses**.
61+
- **Include custom Json payload**: Overrides the webhook JSON used by Action Groups assuming the action group contains a webhook action. Learn more about [webhook action for Log Alerts](./alerts-log-webhook.md).
62+
![Action Overrides for Log Alerts](media/alerts-log/AlertsPreviewOverrideLog.png)
63+
1. When you have finished editing all of the alert rule options, select **Save**.
64+
65+
## Manage log alerts using PowerShell
66+
67+
[!INCLUDE [updated-for-az](../../../includes/updated-for-az.md)]
68+
> [!NOTE]
69+
> PowerShell is not currently supported in API version `2020-08-01`.
70+
71+
Use the PowerShell cmdlets listed below to manage rules with the [Scheduled Query Rules API](/rest/api/monitor/scheduledqueryrule-2018-04-16/scheduled-query-rules).
72+
73+
- [New-AzScheduledQueryRule](/powershell/module/az.monitor/new-azscheduledqueryrule) : PowerShell cmdlet to create a new log alert rule.
74+
- [Set-AzScheduledQueryRule](/powershell/module/az.monitor/set-azscheduledqueryrule) : PowerShell cmdlet to update an existing log alert rule.
75+
- [New-AzScheduledQueryRuleSource](/powershell/module/az.monitor/new-azscheduledqueryrulesource) : PowerShell cmdlet to create or update object specifying source parameters for a log alert. Used as input by [New-AzScheduledQueryRule](/powershell/module/az.monitor/new-azscheduledqueryrule) and [Set-AzScheduledQueryRule](/powershell/module/az.monitor/set-azscheduledqueryrule) cmdlet.
76+
- [New-AzScheduledQueryRuleSchedule](/powershell/module/az.monitor/new-azscheduledqueryruleschedule): PowerShell cmdlet to create or update object specifying schedule parameters for a log alert. Used as input by [New-AzScheduledQueryRule](/powershell/module/az.monitor/new-azscheduledqueryrule) and [Set-AzScheduledQueryRule](/powershell/module/az.monitor/set-azscheduledqueryrule) cmdlet.
77+
- [New-AzScheduledQueryRuleAlertingAction](/powershell/module/az.monitor/new-azscheduledqueryrulealertingaction) : PowerShell cmdlet to create or update object specifying action parameters for a log alert. Used as input by [New-AzScheduledQueryRule](/powershell/module/az.monitor/new-azscheduledqueryrule) and [Set-AzScheduledQueryRule](/powershell/module/az.monitor/set-azscheduledqueryrule) cmdlet.
78+
- [New-AzScheduledQueryRuleAznsActionGroup](/powershell/module/az.monitor/new-azscheduledqueryruleaznsactiongroup) : PowerShell cmdlet to create or update object specifying action groups parameters for a log alert. Used as input by [New-AzScheduledQueryRuleAlertingAction](/powershell/module/az.monitor/new-azscheduledqueryrulealertingaction) cmdlet.
79+
- [New-AzScheduledQueryRuleTriggerCondition](/powershell/module/az.monitor/new-azscheduledqueryruletriggercondition) : PowerShell cmdlet to create or update object specifying trigger condition parameters for log alert. Used as input by [New-AzScheduledQueryRuleAlertingAction](/powershell/module/az.monitor/new-azscheduledqueryrulealertingaction) cmdlet.
80+
- [New-AzScheduledQueryRuleLogMetricTrigger](/powershell/module/az.monitor/new-azscheduledqueryrulelogmetrictrigger) : PowerShell cmdlet to create or update object specifying metric trigger condition parameters for [metric measurement type log alert](./alerts-unified-log.md#calculation-of-measure-based-on-a-numeric-column-such-as-cpu-counter-value). Used as input by [New-AzScheduledQueryRuleTriggerCondition](/powershell/module/az.monitor/new-azscheduledqueryruletriggercondition) cmdlet.
81+
- [Get-AzScheduledQueryRule](/powershell/module/az.monitor/get-azscheduledqueryrule) : PowerShell cmdlet to list existing log alert rules or a specific log alert rule
82+
- [Update-AzScheduledQueryRule](/powershell/module/az.monitor/update-azscheduledqueryrule) : PowerShell cmdlet to enable or disable log alert rule
83+
- [Remove-AzScheduledQueryRule](/powershell/module/az.monitor/remove-azscheduledqueryrule): PowerShell cmdlet to delete an existing log alert rule
84+
> [!NOTE]
85+
> ScheduledQueryRules PowerShell cmdlets can only manage rules created in [this version of the Scheduled Query Rules API](/rest/api/monitor/scheduledqueryrule-2018-04-16/scheduled-query-rules). Log alert rules created using legacy [Log Analytics Alert API](./api-alerts.md) can only be managed using PowerShell only after [switching to Scheduled Query Rules API](../alerts/alerts-log-api-switch.md).
86+
87+
Here are example steps for creating a log alert rule using PowerShell:
88+
```powershell
89+
$source = New-AzScheduledQueryRuleSource -Query 'Heartbeat | summarize AggregatedValue = count() by bin(TimeGenerated, 5m), _ResourceId' -DataSourceId "/subscriptions/a123d7efg-123c-1234-5678-a12bc3defgh4/resourceGroups/contosoRG/providers/microsoft.OperationalInsights/workspaces/servicews"
90+
$schedule = New-AzScheduledQueryRuleSchedule -FrequencyInMinutes 15 -TimeWindowInMinutes 30
91+
$metricTrigger = New-AzScheduledQueryRuleLogMetricTrigger -ThresholdOperator "GreaterThan" -Threshold 2 -MetricTriggerType "Consecutive" -MetricColumn "_ResourceId"
92+
$triggerCondition = New-AzScheduledQueryRuleTriggerCondition -ThresholdOperator "LessThan" -Threshold 5 -MetricTrigger $metricTrigger
93+
$aznsActionGroup = New-AzScheduledQueryRuleAznsActionGroup -ActionGroup "/subscriptions/a123d7efg-123c-1234-5678-a12bc3defgh4/resourceGroups/contosoRG/providers/microsoft.insights/actiongroups/sampleAG" -EmailSubject "Custom email subject" -CustomWebhookPayload "{ `"alert`":`"#alertrulename`", `"IncludeSearchResults`":true }"
94+
$alertingAction = New-AzScheduledQueryRuleAlertingAction -AznsAction $aznsActionGroup -Severity "3" -Trigger $triggerCondition
95+
New-AzScheduledQueryRule -ResourceGroupName "contosoRG" -Location "Region Name for your Application Insights App or Log Analytics Workspace" -Action $alertingAction -Enabled $true -Description "Alert description" -Schedule $schedule -Source $source -Name "Alert Name"
96+
```
97+
Here are example steps for creating a log alert rule using the PowerShell with cross-resource queries:
98+
```powershell
99+
$authorized = @ ("/subscriptions/a123d7efg-123c-1234-5678-a12bc3defgh4/resourceGroups/contosoRG/providers/microsoft.OperationalInsights/workspaces/servicewsCrossExample", "/subscriptions/a123d7efg-123c-1234-5678-a12bc3defgh4/resourceGroups/contosoRG/providers/microsoft.insights/components/serviceAppInsights")
100+
$source = New-AzScheduledQueryRuleSource -Query 'Heartbeat | summarize AggregatedValue = count() by bin(TimeGenerated, 5m), _ResourceId' -DataSourceId "/subscriptions/a123d7efg-123c-1234-5678-a12bc3defgh4/resourceGroups/contosoRG/providers/microsoft.OperationalInsights/workspaces/servicews" -AuthorizedResource $authorized
101+
$schedule = New-AzScheduledQueryRuleSchedule -FrequencyInMinutes 15 -TimeWindowInMinutes 30
102+
$metricTrigger = New-AzScheduledQueryRuleLogMetricTrigger -ThresholdOperator "GreaterThan" -Threshold 2 -MetricTriggerType "Consecutive" -MetricColumn "_ResourceId"
103+
$triggerCondition = New-AzScheduledQueryRuleTriggerCondition -ThresholdOperator "LessThan" -Threshold 5 -MetricTrigger $metricTrigger
104+
$aznsActionGroup = New-AzScheduledQueryRuleAznsActionGroup -ActionGroup "/subscriptions/a123d7efg-123c-1234-5678-a12bc3defgh4/resourceGroups/contosoRG/providers/microsoft.insights/actiongroups/sampleAG" -EmailSubject "Custom email subject" -CustomWebhookPayload "{ `"alert`":`"#alertrulename`", `"IncludeSearchResults`":true }"
105+
$alertingAction = New-AzScheduledQueryRuleAlertingAction -AznsAction $aznsActionGroup -Severity "3" -Trigger $triggerCondition
106+
New-AzScheduledQueryRule -ResourceGroupName "contosoRG" -Location "Region Name for your Application Insights App or Log Analytics Workspace" -Action $alertingAction -Enabled $true -Description "Alert description" -Schedule $schedule -Source $source -Name "Alert Name"
107+
```
108+
You can also create the log alert using a [template and parameters](./alerts-log-create-templates.md) files using PowerShell:
109+
```powershell
110+
Connect-AzAccount
111+
Select-AzSubscription -SubscriptionName <yourSubscriptionName>
112+
New-AzResourceGroupDeployment -Name AlertDeployment -ResourceGroupName ResourceGroupofTargetResource `
113+
-TemplateFile mylogalerttemplate.json -TemplateParameterFile mylogalerttemplate.parameters.json
114+
```
115+
116+
## Next steps
117+
118+
* Learn about [log alerts](./alerts-unified-log.md).
119+
* Create log alerts using [Azure Resource Manager Templates](./alerts-log-create-templates.md).
120+
* Understand [webhook actions for log alerts](./alerts-log-webhook.md).
121+
* Learn more about [log queries](../logs/log-query-overview.md).
16.9 KB
Loading
106 KB
Loading
45.6 KB
Loading
76.1 KB
Loading
42.9 KB
Loading
19.6 KB
Loading

0 commit comments

Comments
 (0)