< Back

Add-AzureRmMetricAlertRule

Tue Jan 29, 2019 9:48 pm

NAME Add-AzureRmMetricAlertRule



SYNOPSIS

Adds or updates a metric-based alert rule.





SYNTAX

Add-AzureRmMetricAlertRule [-Action <System.Collections.Generic.List`1[Microsoft.Azure.Management.Monitor.Management.Models.RuleAction]>]

[-DefaultProfile <IAzureContextContainer>] [-Description <String>] [-DisableRule] -Location <String> -MetricName <String> -Name <String> -Operator

{GreaterThan | GreaterThanOrEqual | LessThan | LessThanOrEqual} -ResourceGroupName <String> -TargetResourceId <String> -Threshold <Double>

-TimeAggregationOperator {Average | Minimum | Maximum | Total | Last} -WindowSize <TimeSpan> [<CommonParameters>]





DESCRIPTION

The Add-AzureRmMetricAlertRule cmdlet adds or updates a metric-based alert rule. The added rule is associated with a resource group and has a

name. This cmdlet implements the ShouldProcess pattern, i.e. it might request confirmation from the user before actually creating, modifying, or

removing the resource.





PARAMETERS

-Action <System.Collections.Generic.List`1[Microsoft.Azure.Management.Monitor.Management.Models.RuleAction]>

Specifies a comma-separated list of actions.



Required? false

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-DefaultProfile <IAzureContextContainer>

The credentials, account, tenant, and subscription used for communication with azure



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Description <String>

Specifies a description of the rule.



Required? false

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-DisableRule [<SwitchParameter>]

Disables the rule. If you do not specify this parameter, the rule is enabled.



Required? false

Position? named

Default value False

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Location <String>

Specifies the location where the rule is defined.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-MetricName <String>

Specifies the name of the metric the rule is monitoring. Specify this parameter only for metric-based rules.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Name <String>

Specifies the name of the rule.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Operator <ConditionOperator>

Specifies the relational operator for the condition of the rule. The acceptable values for this parameter are:



- GreaterThan



- GreaterThanOrEqual



- LessThan



- LessThanOrEqual



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-ResourceGroupName <String>

Specifies the name of the resource group for the rule.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-TargetResourceId <String>

Specifies the ID of the resource the rule is monitoring. NOTE: This property cannot be updated for an existing alert rule.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Threshold <Double>

Specifies the threshold of the rule.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-TimeAggregationOperator <TimeAggregationOperator>

Specifies the aggregation operator to apply to the time window when the rule is being evaluated.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-WindowSize <TimeSpan>

Specifies the time window size for the rule to compute its data.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

None

This cmdlet does not accept any input.





OUTPUTS

Microsoft.Azure.Commands.Insights.OutputClasses.PSAddAlertRuleOperationResponse







NOTES









Example 1: Add a metric alert rule to a website



PS C:\\>Add-AzureRMMetricAlertRule -Name "metricRule5" -Location "East US" -ResourceGroup "Default-Web-EastUS" -Operator GreaterThan -Threshold 2

-WindowSize 00:05:00 -MetricName "Requests" -Description "Pura Vida" -TimeAggregationOperator Total

RequestId StatusCode

--------- ----------

33574ccf-0b01-43b4-aa97-87e6bbcf1c11 Created



This command creates a metric alert rule for a website.





Example 2: Disable a rule



PS C:\\>Add-AzureRMMetricAlertRule -Name "metricRule5" -Location "East US" -ResourceGroup Default-Web-EastUS -Operator GreaterThan -Threshold 2

-WindowSize 00:05:00 -MetricName "Requests" -TimeAggregationOperator Total

RequestId StatusCode

--------- ----------

96c489f1-8529-46e1-a76d-2c1463ca3116 OK



This command disables a rule. If the rule does not exist, it creates it disabled. If the rule exists, then it just disables it.





Example 3: Add a rule with actions



PS C:\\>Add-AzureRmMetricAlertRule -Name "metricRule5" -Location "East US" -ResourceGroup "Default-Web-EastUS" -Operator GreaterThan -Threshold 1

-TargetResourceId "/subscriptions/b93fb07a-6f93-30be-bf3e-4f0deca15f4f/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/mywebsite"

-MetricName "Requests" -TimeAggregationOperator Total

RequestId StatusCode

--------- ----------

9a5bc388-c7ac-4dc6-aa70-f4bc29c2c712 OK



This command creates a metric alert rule for a website.







RELATED LINKS

Online Version: https://docs.microsoft.com/en-us/powers ... calertrule

Set-AzureRmActivityLogAlert

Add-AzureRmWebtestAlertRule

Get-AzureRmAlertHistory

Get-AzureRmAlertRule

New-AzureRmAlertRuleEmail

New-AzureRmAlertRuleWebhook

Remove-AzureRmAlertRule