Add-AzMetricAlertRuleV2
Menambahkan atau memperbarui aturan pemberitahuan berbasis metrik V2 (non-klasik).
Sintaks
Add-AzMetricAlertRuleV2
-Name <String>
-ResourceGroupName <String>
-WindowSize <TimeSpan>
-Frequency <TimeSpan>
-TargetResourceId <String>
-Condition <System.Collections.Generic.List`1[Microsoft.Azure.Commands.Insights.OutputClasses.IPSMultiMetricCriteria]>
[-AutoMitigate <Boolean>]
[-ActionGroup <ActivityLogAlertActionGroup[]>]
[-ActionGroupId <String[]>]
[-DisableRule]
[-Description <String>]
-Severity <Int32>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Add-AzMetricAlertRuleV2
-Name <String>
-ResourceGroupName <String>
-WindowSize <TimeSpan>
-Frequency <TimeSpan>
-TargetResourceScope <String[]>
[-TargetResourceType <String>]
[-TargetResourceRegion <String>]
-Condition <System.Collections.Generic.List`1[Microsoft.Azure.Commands.Insights.OutputClasses.IPSMultiMetricCriteria]>
[-AutoMitigate <Boolean>]
[-ActionGroup <ActivityLogAlertActionGroup[]>]
[-ActionGroupId <String[]>]
[-DisableRule]
[-Description <String>]
-Severity <Int32>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Deskripsi
Menambahkan atau memperbarui aturan pemberitahuan berbasis metrik V2 (non-klasik). Aturan yang ditambahkan dikaitkan dengan grup sumber daya dan memiliki nama. Cmdlet ini mengimplementasikan pola ShouldProcess, yaitu mungkin meminta konfirmasi dari pengguna sebelum benar-benar membuat, memodifikasi, atau menghapus sumber daya.
Contoh
Contoh 1: Menambahkan aturan pemberitahuan metrik ke komputer virtual
$act = [Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertActionGroup]::New("/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/default-activitylogalerts/providers/Microsoft.Insights/actiongroups/actionGroupDemo")
Add-AzMetricAlertRuleV2 -Name PS3182019 -ResourceGroupName xxxxRG -WindowSize 0:5 -Frequency 0:5 -TargetResourceScope "/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/012345/providers/Microsoft.Compute/virtualMachines/VM1", "/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/012345/providers/Microsoft.Compute/virtualMachines/VM2" -TargetResourceType "Microsoft.Compute/virtualMachines" -TargetResourceRegion "eastus" -Description "This is description" -Severity 4 -ActionGroup $act -Condition $condition
Description : This is description
Severity : 4
Enabled : True
Scopes : {/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/012345/providers/Microsoft.Compute/virtualMachines/VM1,
/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/012345/providers/Microsoft.Compute/virtualMachines/VM2}
EvaluationFrequency : 00:05:00
WindowSize : 00:05:00
TargetResourceType : Microsoft.Compute/virtualMachines
TargetResourceRegion : eastus
Criteria : Microsoft.Azure.Management.Monitor.Models.MetricAlertMultipleResourceMultipleMetricCriteria
AutoMitigate :
Actions : {/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/default-activitylogalerts/providers/Microsoft.Insights/actiongroups/demo}
LastUpdatedTime :
Id : /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/xxxxRG/providers/Microsoft.Insights/metricAlerts/PS3182019
Name : PS3182019
Type : Microsoft.Insights/metricAlerts
Location : global
Tags :
Perintah ini membuat aturan pemberitahuan metrik untuk komputer virtual. $condition adalah output cmdlet New-AzMetricAlertRuleV2Criteria
Contoh 2: Menambahkan aturan pemberitahuan metrik untuk semua komputer virtual dalam langganan
$act = [Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertActionGroup]::New("/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/default-activitylogalerts/providers/Microsoft.Insights/actiongroups/actionGroupDemo")
Add-AzMetricAlertRuleV2 -Name AllVM -ResourceGroupName xxxxRG -WindowSize 0:5 -Frequency 0:5 -TargetResourceScope "/subscriptions/00000000-0000-0000-0000-0000000" -TargetResourceType "Microsoft.Compute/virtualMachines" -TargetResourceRegion "eastus" -Description "This is description" -Severity 4 -ActionGroup $act -Condition $condition
Description : This is description
Severity : 4
Enabled : True
Scopes : {/subscriptions/00000000-0000-0000-0000-0000000}
EvaluationFrequency : 00:05:00
WindowSize : 00:05:00
TargetResourceType : Microsoft.Compute/virtualMachines
TargetResourceRegion : eastus
Criteria : Microsoft.Azure.Management.Monitor.Models.MetricAlertMultipleResourceMultipleMetricCriteria
AutoMitigate :
Actions : {/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/default-activitylogalerts/providers/Microsoft.Insights/actiongroups/demo}
LastUpdatedTime :
Id : /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/xxxxRG/providers/Microsoft.Insights/metricAlerts/AllVM
Name : AllVM
Type : Microsoft.Insights/metricAlerts
Location : global
Tags :
Perintah ini membuat aturan pemberitahuan metrik untuk semua komputer virtual dalam langganan yang berada di eastus
Contoh 3: Menonaktifkan aturan pemberitahuan metrik
Get-AzMetricAlertRuleV2 -ResourceGroupName alertstest -Name TestAlertRule | Add-AzMetricAlertRuleV2 -DisableRule
Description : This new Metric alert rule was created from Powershell version: 1.0.1
Severity : 4
Enabled : False
Scopes : {/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/alertstest/providers/Microsoft.Insights/components/alertstestFunction}
EvaluationFrequency : 00:05:00
WindowSize : 00:05:00
TargetResourceType :
TargetResourceRegion :
Criteria : Microsoft.Azure.Management.Monitor.Models.MetricAlertSingleResourceMultipleMetricCriteria
AutoMitigate :
Actions : {/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/default-activitylogalerts/providers/Microsoft.Insights/actiongroups/demo1}
LastUpdatedTime :
Id : /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/alertstest/providers/Microsoft.Insights/metricAlerts/TestAlertRule
Name : TestAlertRule
Type : Microsoft.Insights/metricAlerts
Location : global
Tags :
Perintah ini menonaktifkan aturan pemberitahuan metrik. Di sini, kami adalah output perpipaan dari Get-AzMetricAlertRuleV2 ke Add-AzMetricAlertRuleV2
Contoh 4: Menambahkan aturan pemberitahuan metrik dengan dimensi
$act = [Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertActionGroup]::New("/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/default-activitylogalerts/providers/Microsoft.Insights/actiongroups/actionGroupDemo")
$dim1 = New-AzMetricAlertRuleV2DimensionSelection -DimensionName "availabilityResult/name" -ValuesToInclude "gdtest"
$dim2 = New-AzMetricAlertRuleV2DimensionSelection -DimensionName "availabilityResult/location" -ValuesToInclude "*"
$criteria = New-AzMetricAlertRuleV2Criteria -MetricName "availabilityResults/availabilityPercentage" -DimensionSelection $dim1,$dim2 -TimeAggregation Average -Operator GreaterThan -Threshold 2
Add-AzMetricAlertRuleV2 -Name AlertWithDim -ResourceGroupName alertstest -WindowSize 00:05:00 -Frequency 00:05:00 -TargetResourceId "/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/alertstest/providers/Microsoft.Insights/components/alertstestFunction" -Condition $criteria -ActionGroup $act -DisableRule -Severity 4
Description : This new Metric alert rule was created from Powershell version: 1.0.0
Severity : 4
Enabled : False
Scopes : {/subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/alertstest/providers/Microsoft.Insights/components/alertstestFunction}
EvaluationFrequency : 00:05:00
WindowSize : 00:05:00
TargetResourceType :
TargetResourceRegion :
Criteria : Microsoft.Azure.Management.Monitor.Models.MetricAlertSingleResourceMultipleMetricCriteria
AutoMitigate :
Actions : {/subscriptions/00000000-0000-0000-0000-0000000/resourcegroups/default-activitylogalerts/providers/Microsoft.Insights/actiongroups/actionGroupDemo}
LastUpdatedTime :
Id : /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/alertstest/providers/Microsoft.Insights/metricAlerts/AlertWithDim
Name : AlertWithDim
Type : Microsoft.Insights/metricAlerts
Location : global
Tags :
Untuk membuat aturan pemberitahuan metrik yang lebih kompleks seperti yang melibatkan pemilihan nilai dimensi atau memiliki beberapa kriteria, Anda dapat menggunakan cmdlet pembantu New-AzMetricAlertRuleV2DimensionSelection dan New-AzMetricAlertRuleV2Criteria.
Set cmdlet di atas akan membuat aturan pemberitahuan metrik dengan dimensi.
Parameter
-ActionGroup
Grup Tindakan untuk aturan
Jenis: | ActivityLogAlertActionGroup[] |
Alias: | Actions |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | True |
Terima karakter wildcard: | False |
-ActionGroupId
Id Grup Tindakan untuk aturan
Jenis: | String[] |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | True |
Terima karakter wildcard: | False |
-AutoMitigate
Bendera yang menunjukkan apakah pemberitahuan harus diselesaikan secara otomatis atau tidak
Jenis: | Boolean |
Position: | Named |
Nilai default: | True |
Diperlukan: | False |
Terima input alur: | True |
Terima karakter wildcard: | False |
-Condition
Kondisi untuk aturan
Jenis: | List<T>[IPSMultiMetricCriteria] |
Alias: | Criteria |
Position: | Named |
Nilai default: | None |
Diperlukan: | True |
Terima input alur: | True |
Terima karakter wildcard: | False |
-Confirm
Meminta Anda mengonfirmasi sebelum menjalankan cmdlet.
Jenis: | SwitchParameter |
Alias: | cf |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | False |
Terima karakter wildcard: | False |
-DefaultProfile
Kredensial, akun, penyewa, dan langganan yang digunakan untuk komunikasi dengan Azure.
Jenis: | IAzureContextContainer |
Alias: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | False |
Terima karakter wildcard: | False |
-Description
Deskripsi aturan pemberitahuan metrik
Jenis: | String |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | True |
Terima karakter wildcard: | False |
-DisableRule
Bendera nonaktifkan aturan (status)
Jenis: | SwitchParameter |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | True |
Terima karakter wildcard: | False |
-Frequency
Frekuensi evaluasi untuk aturan
Jenis: | TimeSpan |
Alias: | EvaluationFrequency |
Position: | Named |
Nilai default: | None |
Diperlukan: | True |
Terima input alur: | True |
Terima karakter wildcard: | False |
-Name
Nama aturan pemberitahuan metrik
Jenis: | String |
Position: | Named |
Nilai default: | None |
Diperlukan: | True |
Terima input alur: | True |
Terima karakter wildcard: | False |
-ResourceGroupName
Nama Grup Sumber Daya
Jenis: | String |
Alias: | ResourceGroup |
Position: | Named |
Nilai default: | None |
Diperlukan: | True |
Terima input alur: | True |
Terima karakter wildcard: | False |
-Severity
Tingkat keparahan untuk aturan pemberitahuan metrik
Jenis: | Int32 |
Position: | Named |
Nilai default: | None |
Diperlukan: | True |
Terima input alur: | True |
Terima karakter wildcard: | False |
-TargetResourceId
Id sumber daya target untuk aturan
Jenis: | String |
Position: | Named |
Nilai default: | None |
Diperlukan: | True |
Terima input alur: | True |
Terima karakter wildcard: | False |
-TargetResourceRegion
Wilayah sumber daya target untuk aturan
Jenis: | String |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | True |
Terima karakter wildcard: | False |
-TargetResourceScope
Cakupan sumber daya target untuk aturan
Jenis: | String[] |
Alias: | Scopes |
Position: | Named |
Nilai default: | None |
Diperlukan: | True |
Terima input alur: | True |
Terima karakter wildcard: | False |
-TargetResourceType
Jenis sumber daya target untuk aturan
Jenis: | String |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | True |
Terima karakter wildcard: | False |
-WhatIf
Menunjukkan apa yang akan terjadi jika cmdlet berjalan. Cmdlet tidak dijalankan.
Jenis: | SwitchParameter |
Alias: | wi |
Position: | Named |
Nilai default: | None |
Diperlukan: | False |
Terima input alur: | False |
Terima karakter wildcard: | False |
-WindowSize
Ukuran jendela untuk aturan
Jenis: | TimeSpan |
Position: | Named |
Nilai default: | None |
Diperlukan: | True |
Terima input alur: | True |
Terima karakter wildcard: | False |
Input
String[]
List<T>[[Microsoft.Azure.Commands.Insights.OutputClasses.IPSMultiMetricCriteria, Microsoft.Azure.PowerShell.Cmdlets.Monitor, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null]]
Microsoft.Azure.Management.Monitor.Models.ActivityLogAlertActionGroup[]