共用方式為


New-AzPrometheusRuleGroup

建立或更新 Prometheus 規則群組定義。

語法

New-AzPrometheusRuleGroup
   -ResourceGroupName <String>
   -RuleGroupName <String>
   [-SubscriptionId <String>]
   -Location <String>
   -Rule <IPrometheusRule[]>
   -Scope <String[]>
   [-ClusterName <String>]
   [-Description <String>]
   [-Enabled]
   [-Interval <TimeSpan>]
   [-Tag <Hashtable>]
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

建立或更新 Prometheus 規則群組定義。

範例

範例 1:使用一個規則建立 Prometheus 規則群組定義。

$rule1 = New-AzPrometheusRuleObject -Record "job_type:billing_jobs_duration_seconds:99p5m"
$scope = "/subscriptions/fffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/MyresourceGroup/providers/microsoft.monitor/accounts/MyAccounts"
New-AzPrometheusRuleGroup -ResourceGroupName MyresourceGroup -RuleGroupName MyRuleGroup -Location eastus -Rule $rule1 -Scope $scope -Enabled

Name        Location ClusterName Enabled
----        -------- ----------- -------
MyRuleGroup eastus               True

使用一個規則建立 Prometheus 規則群組定義。

範例 2:使用規則建立 Prometheus 規則群組定義。

$rule1 = New-AzPrometheusRuleObject -Record "job_type:billing_jobs_duration_seconds:99p5m"
$action =  New-AzPrometheusRuleGroupActionObject -ActionGroupId /subscriptions/fffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/MyresourceGroup/providers/microsoft.insights/actiongroups/MyActionGroup -ActionProperty @{"key1" = "value1"}
$Timespan = New-TimeSpan -Minutes 15
$rule2 = New-AzPrometheusRuleObject -Alert Billing_Processing_Very_Slow -Expression "job_type:billing_jobs_duration_seconds:99p5m > 30" -Enabled $false -Severity 3 -For $Timespan -Label @{"team"="prod"} -Annotation @{"annotation" = "value"} -ResolveConfigurationAutoResolved $true -ResolveConfigurationTimeToResolve $Timespan -Action $action
$rules = @($rule1, $rule2)
$scope = "/subscriptions/fffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/MyresourceGroup/providers/microsoft.monitor/accounts/MyAccounts"
New-AzPrometheusRuleGroup -ResourceGroupName MyresourceGroup -RuleGroupName MyRuleGroup -Location eastus -Rule $rule1 -Scope $scope -Enabled

Name        Location ClusterName Enabled
----        -------- ----------- -------
MyRuleGroup eastus               True

使用規則建立 Prometheus 規則群組定義。

參數

-ClusterName

將規則套用至來自特定叢集的數據。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Confirm

執行 Cmdlet 之前先提示您確認。

類型:SwitchParameter
別名:cf
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DefaultProfile

DefaultProfile 參數無法運作。 如果針對不同的訂用帳戶執行 Cmdlet,請使用 SubscriptionId 參數。

類型:PSObject
別名:AzureRMContext, AzureCredential
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Description

規則群組描述。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Enabled

啟用/停用規則群組。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Interval

執行以 ISO 8601 持續時間格式表示之 Prometheus 規則群組的間隔。 應介於 1 到 15 分鐘之間

類型:TimeSpan
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Location

資源所在的地理位置

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-ResourceGroupName

資源群組的名稱。 名稱不區分大小寫。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-Rule

定義 Prometheus 規則群組中的規則。 若要建構,請參閱 RULE 屬性和建立哈希表的 NOTES 一節。

類型:IPrometheusRule[]
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-RuleGroupName

規則群組的名稱。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-Scope

目標 Azure 監視器工作區資源標識碼。 此 API 版本目前僅限於使用一個範圍建立。 這可能會在未來變更。

類型:String[]
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-SubscriptionId

目標訂用帳戶的標識碼。

類型:String
Position:Named
預設值:(Get-AzContext).Subscription.Id
必要:False
接受管線輸入:False
接受萬用字元:False

-Tag

資源標籤。

類型:Hashtable
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-WhatIf

顯示執行 Cmdlet 後會發生的情況。 未執行 Cmdlet。

類型:SwitchParameter
別名:wi
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

輸出

IPrometheusRuleGroupResource