Alert Rules - Update

匯報 現有的傳統計量 AlertRuleResource。 若要更新其他欄位,請使用 CreateOrUpdate 方法。

PATCH https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}?api-version=2016-03-01

URI 參數

名稱 位於 必要 類型 Description
resourceGroupName
path True

string

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

ruleName
path True

string

規則的名稱。

subscriptionId
path True

string

目標訂用帳戶的標識碼。

api-version
query True

string

用於此作業的 API 版本。

要求本文

名稱 必要 類型 Description
properties.condition True RuleCondition:

導致啟動警示規則的條件。

properties.isEnabled True

boolean

指出是否啟用警示規則的旗標。

properties.name True

string

警示規則的名稱。

properties.action RuleAction:

當警示規則變成作用中時,以及解決警示條件時所執行的動作。

properties.actions RuleAction[]:

當警示規則變成作用中時,以及解決警示條件時所執行的動作陣列。

properties.description

string

警示電子郵件中將包含的警示規則描述。

properties.provisioningState

string

布建狀態。

tags

object

資源標籤

回應

名稱 類型 Description
200 OK

AlertRuleResource

成功要求更新警示規則

201 Created

AlertRuleResource

成功要求更新導致建立警示規則的警示規則

Other Status Codes

ErrorResponse

描述作業失敗原因的錯誤回應。

安全性

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

名稱 Description
user_impersonation 模擬您的用戶帳戶

範例

Patch an alert rule

Sample Request

PATCH https://management.azure.com/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourcegroups/Rac46PostSwapRG/providers/Microsoft.Insights/alertrules/chiricutin?api-version=2016-03-01

{
  "tags": {
    "$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary"
  },
  "properties": {
    "name": "chiricutin",
    "description": "Pura Vida",
    "isEnabled": true,
    "condition": {
      "odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
      "dataSource": {
        "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
        "resourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest",
        "metricName": "Requests"
      },
      "operator": "GreaterThan",
      "threshold": 3,
      "windowSize": "PT5M",
      "timeAggregation": "Total"
    },
    "actions": []
  }
}

Sample Response

{
  "id": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/microsoft.insights/alertrules/chiricutin",
  "name": "chiricutin",
  "type": "Microsoft.Insights/alertRules",
  "location": "West US",
  "tags": {
    "$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary"
  },
  "properties": {
    "name": "chiricutin",
    "description": "Pura Vida",
    "isEnabled": true,
    "condition": {
      "odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
      "dataSource": {
        "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
        "resourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest",
        "metricName": "Requests"
      },
      "operator": "GreaterThan",
      "threshold": 3,
      "windowSize": "PT5M",
      "timeAggregation": "Total"
    },
    "lastUpdatedTime": "2016-11-23T21:23:52.0221265Z",
    "actions": []
  }
}
{
  "id": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/microsoft.insights/alertrules/chiricutin",
  "name": "chiricutin",
  "type": "Microsoft.Insights/alertRules",
  "location": "West US",
  "tags": {
    "$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary"
  },
  "properties": {
    "name": "chiricutin",
    "description": "Pura Vida",
    "isEnabled": true,
    "condition": {
      "odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
      "dataSource": {
        "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
        "resourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest",
        "metricName": "Requests"
      },
      "operator": "GreaterThan",
      "threshold": 3,
      "windowSize": "PT5M",
      "timeAggregation": "Total"
    },
    "lastUpdatedTime": "2016-11-23T21:23:52.0221265Z",
    "actions": []
  }
}

定義

名稱 Description
AlertRuleResource

警示規則資源。

AlertRuleResourcePatch

修補作業的警示規則物件。

ConditionOperator

規則條件中允許的運算符。

ErrorResponse

描述錯誤回應的格式。

LocationThresholdRuleCondition

根據特定位置數目失敗的規則條件。

ManagementEventAggregationCondition

收集的資料應如何隨著時間結合。

ManagementEventRuleCondition

管理事件規則條件。

RuleEmailAction

指定評估規則條件時傳送電子郵件的動作。 在此情況下,鑒別子一律為 RuleEmailAction。

RuleManagementEventClaimsDataSource

規則管理事件數據源的宣告。

RuleManagementEventDataSource

規則管理事件數據源。 在此情況下,鑒別子字段一律為 RuleManagementEventDataSource。

RuleMetricDataSource

規則計量數據源。 在此情況下,鑒別子值一律為 RuleMetricDataSource。

RuleWebhookAction

指定要在評估規則條件時張貼至服務的動作。 在此情況下,鑒別子一律為 RuleWebhookAction。

ThresholdRuleCondition

以超出閾值的計量為基礎的規則條件。

TimeAggregationOperator

規則中允許的匯總運算符。

AlertRuleResource

警示規則資源。

名稱 類型 Description
id

string

Azure 資源標識碼

location

string

資源位置

name

string

Azure 資源名稱

properties.action RuleAction:

當警示規則變成作用中,以及解決警示條件時所執行的動作。

properties.actions RuleAction[]:

當警示規則變成作用中時,以及解決警示條件時所執行的動作陣列。

properties.condition RuleCondition:

導致啟動警示規則的條件。

properties.description

string

將包含在警示電子郵件中的警示規則描述。

properties.isEnabled

boolean

旗標,指出是否啟用警示規則。

properties.lastUpdatedTime

string

上次以ISO8601格式更新規則的時間。

properties.name

string

警示規則的名稱。

properties.provisioningState

string

布建狀態。

tags

object

資源標籤

type

string

Azure 資源類型

AlertRuleResourcePatch

修補作業的警示規則物件。

名稱 類型 Description
properties.action RuleAction:

當警示規則變成作用中,以及解決警示條件時所執行的動作。

properties.actions RuleAction[]:

當警示規則變成作用中時,以及解決警示條件時所執行的動作陣列。

properties.condition RuleCondition:

導致啟動警示規則的條件。

properties.description

string

將包含在警示電子郵件中的警示規則描述。

properties.isEnabled

boolean

旗標,指出是否啟用警示規則。

properties.lastUpdatedTime

string

上次以ISO8601格式更新規則的時間。

properties.name

string

警示規則的名稱。

properties.provisioningState

string

布建狀態。

tags

object

資源標籤

ConditionOperator

規則條件中允許的運算符。

名稱 類型 Description
GreaterThan

string

GreaterThanOrEqual

string

LessThan

string

LessThanOrEqual

string

ErrorResponse

描述錯誤回應的格式。

名稱 類型 Description
code

string

錯誤碼

message

string

錯誤訊息,指出作業失敗的原因。

LocationThresholdRuleCondition

根據特定位置數目失敗的規則條件。

名稱 類型 Description
dataSource RuleDataSource:

規則從中收集數據的資源。 針對此類型 dataSource,一律為 RuleMetricDataSource 類型。

failedLocationCount

integer

必須無法啟動警示的位置數目。

odata.type string:

Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition

會指定條件的類型。 這可以是下列三種類型之一:ManagementEventRuleCondition (根據計量) 的閾值,發生管理事件) 、LocationThresholdRuleCondition ( () 。

windowSize

string

ISO 8601 持續時間格式 (期間) ,用來根據閾值監視警示活動。 如果指定的話,它必須介於 5 分鐘到 1 天之間。

ManagementEventAggregationCondition

收集的資料應如何隨著時間結合。

名稱 類型 Description
operator

ConditionOperator

條件運算元。

threshold

number

啟動警示的臨界值。

windowSize

string

ISO 8601 持續時間格式 (期間) ,用來根據閾值監視警示活動。 如果指定的話,它必須介於 5 分鐘到 1 天之間。

ManagementEventRuleCondition

管理事件規則條件。

名稱 類型 Description
aggregation

ManagementEventAggregationCondition

收集的數據應該如何隨著時間與警示啟動的時間合併。 請注意,管理事件警示彙總是選用的 - 若未提供,則任何事件都會導致警示啟動。

dataSource RuleDataSource:

規則從中收集數據的資源。 針對此類型 dataSource,一律為 RuleMetricDataSource 類型。

odata.type string:

Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition

會指定條件的類型。 這可以是下列三種類型之一:ManagementEventRuleCondition (根據計量) 的閾值,發生管理事件) 、LocationThresholdRuleCondition ( () 。

RuleEmailAction

指定評估規則條件時傳送電子郵件的動作。 在此情況下,鑒別子一律為 RuleEmailAction。

名稱 類型 Description
customEmails

string[]

系統管理員自定義電子郵件地址的清單,以通知警示的啟用。

odata.type string:

Microsoft.Azure.Management.Insights.Models.RuleEmailAction

會指定動作的類型。 動作有兩種類型:RuleEmailAction 和 RuleWebhookAction。

sendToServiceOwners

boolean

啟動警示時,是否應該通知服務的系統管理員 (服務和共同管理員)。

RuleManagementEventClaimsDataSource

規則管理事件數據源的宣告。

名稱 類型 Description
emailAddress

string

電子郵件位址。

RuleManagementEventDataSource

規則管理事件數據源。 在此情況下,鑒別子字段一律為 RuleManagementEventDataSource。

名稱 類型 Description
claims

RuleManagementEventClaimsDataSource

宣告。

eventName

string

事件名稱。

eventSource

string

事件來源。

legacyResourceId

string

規則所監視之資源的舊版資源標識符。 注意:無法更新現有規則的這個屬性。

level

string

層級。

metricNamespace

string

計量的命名空間。

odata.type string:

Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource

指定數據源的類型。 規則數據源有兩種類型:RuleMetricDataSource 和 RuleManagementEventDataSource

operationName

string

應檢查的作業名稱。 如果未提供名稱,則任何作業都相符。

resourceGroupName

string

資源組名。

resourceLocation

string

資源的位置。

resourceProviderName

string

資源提供者名稱。

resourceUri

string

規則所監視之資源的資源標識碼。 注意:無法更新現有規則的這個屬性。

status

string

應檢查的作業狀態。 如果未提供狀態,則任何狀態都相符。

subStatus

string

子狀態。

RuleMetricDataSource

規則計量數據源。 在此情況下,鑒別子值一律為 RuleMetricDataSource。

名稱 類型 Description
legacyResourceId

string

規則所監視之資源的舊版資源標識符。 注意:無法更新現有規則的這個屬性。

metricName

string

定義規則監視之計量的名稱。

metricNamespace

string

計量的命名空間。

odata.type string:

Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource

指定數據源的類型。 規則數據源有兩種類型:RuleMetricDataSource 和 RuleManagementEventDataSource

resourceLocation

string

資源的位置。

resourceUri

string

規則所監視之資源的資源標識碼。 注意:無法更新現有規則的這個屬性。

RuleWebhookAction

指定要在評估規則條件時張貼至服務的動作。 在此情況下,鑒別子一律為 RuleWebhookAction。

名稱 類型 Description
odata.type string:

Microsoft.Azure.Management.Insights.Models.RuleWebhookAction

會指定動作的類型。 動作有兩種類型:RuleEmailAction 和 RuleWebhookAction。

properties

object

要包含在後續作業中的自定義屬性字典。 這些數據會附加至 Webhook 承載。

serviceUri

string

當警示啟動或解決時,要張貼通知的服務 URI。

ThresholdRuleCondition

以超出閾值的計量為基礎的規則條件。

名稱 類型 Description
dataSource RuleDataSource:

規則從中收集數據的資源。 針對此類型 dataSource,一律為 RuleMetricDataSource 類型。

odata.type string:

Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition

會指定條件的類型。 這可以是下列三種類型之一:ManagementEventRuleCondition (根據計量) 的閾值,發生管理事件) 、LocationThresholdRuleCondition ( () 。

operator

ConditionOperator

用來比較數據和臨界值的運算符。

threshold

number

啟動警示的臨界值。

timeAggregation

TimeAggregationOperator

時間匯總運算子。 收集的數據應如何隨著時間合併。 預設值為 Metric 的 PrimaryAggregationType。

windowSize

string

ISO 8601 持續時間格式 (期間) ,用來根據閾值監視警示活動。 如果指定的話,它必須介於 5 分鐘到 1 天之間。

TimeAggregationOperator

規則中允許的匯總運算符。

名稱 類型 Description
Average

string

Last

string

Maximum

string

Minimum

string

Total

string