你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
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 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
resource
|
path | True |
string |
资源组的名称。 此名称不区分大小写。 |
rule
|
path | True |
string |
规则的名称。 |
subscription
|
path | True |
string |
目标订阅的 ID。 |
api-version
|
query | True |
string |
要用于此操作的 API 版本。 |
请求正文
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
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 |
资源标记 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
成功请求更新警报规则 |
|
201 Created |
成功请求更新导致创建警报规则的警报规则 |
|
Other Status Codes |
描述操作失败原因的错误响应。 |
安全性
azure_auth
Azure Active Directory OAuth2 流
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名称 | 说明 |
---|---|
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": []
}
}
定义
名称 | 说明 |
---|---|
Alert |
警报规则资源。 |
Alert |
修补操作的警报规则对象。 |
Condition |
规则条件中允许的运算符。 |
Error |
描述错误响应的格式。 |
Location |
基于一定数量的位置失败的规则条件。 |
Management |
随着时间推移,收集的数据应如何组合。 |
Management |
管理事件规则条件。 |
Rule |
指定在计算规则条件时发送电子邮件的操作。 在这种情况下,鉴别器始终为 RuleEmailAction。 |
Rule |
规则管理事件数据源的声明。 |
Rule |
规则管理事件数据源。 在这种情况下,鉴别器字段始终为 RuleManagementEventDataSource。 |
Rule |
规则指标数据源。 在这种情况下,鉴别器值始终为 RuleMetricDataSource。 |
Rule |
指定在计算规则条件时要发布到服务的操作。 在这种情况下,鉴别器始终为 RuleWebhookAction。 |
Threshold |
基于越过阈值的指标的规则条件。 |
Time |
规则中允许的聚合运算符。 |
AlertRuleResource
警报规则资源。
名称 | 类型 | 说明 |
---|---|---|
id |
string |
Azure 资源 ID |
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
修补操作的警报规则对象。
名称 | 类型 | 说明 |
---|---|---|
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
规则条件中允许的运算符。
名称 | 类型 | 说明 |
---|---|---|
GreaterThan |
string |
|
GreaterThanOrEqual |
string |
|
LessThan |
string |
|
LessThanOrEqual |
string |
ErrorResponse
描述错误响应的格式。
名称 | 类型 | 说明 |
---|---|---|
code |
string |
错误代码 |
message |
string |
指示操作失败原因的错误消息。 |
LocationThresholdRuleCondition
基于一定数量的位置失败的规则条件。
名称 | 类型 | 说明 |
---|---|---|
dataSource | RuleDataSource: |
规则从中收集数据的资源。 对于此类型,dataSource 将始终为 RuleMetricDataSource 类型。 |
failedLocationCount |
integer |
必须无法激活警报的位置数。 |
odata.type |
string:
Microsoft. |
指定条件的类型。 这可以是以下三种类型之一:ManagementEventRuleCondition (管理事件) 、LocationThresholdRuleCondition ((基于 Web 测试) 的失败次数)和 ThresholdRuleCondition (基于指标) 的阈值。 |
windowSize |
string |
iso 8601 持续时间格式 (的时间段) ,用于根据阈值监视警报活动。 如果指定,则它必须介于 5 分钟到 1 天之间。 |
ManagementEventAggregationCondition
随着时间推移,收集的数据应如何组合。
名称 | 类型 | 说明 |
---|---|---|
operator |
条件运算符。 |
|
threshold |
number |
激活警报的阈值。 |
windowSize |
string |
iso 8601 持续时间格式 (的时间段) ,用于根据阈值监视警报活动。 如果指定,则它必须介于 5 分钟到 1 天之间。 |
ManagementEventRuleCondition
管理事件规则条件。
名称 | 类型 | 说明 |
---|---|---|
aggregation |
收集的数据应如何随着时间推移以及警报的激活时间组合在一起。 请注意,对于管理事件警报,聚合是可选的;如果未提供任何聚合,则任何事件都将导致激活警报。 |
|
dataSource | RuleDataSource: |
规则从中收集数据的资源。 对于此类型,dataSource 将始终为 RuleMetricDataSource 类型。 |
odata.type |
string:
Microsoft. |
指定条件的类型。 这可以是以下三种类型之一:ManagementEventRuleCondition (管理事件) 、LocationThresholdRuleCondition ((基于 Web 测试) 的失败次数)和 ThresholdRuleCondition (基于指标) 的阈值。 |
RuleEmailAction
指定在计算规则条件时发送电子邮件的操作。 在这种情况下,鉴别器始终为 RuleEmailAction。
名称 | 类型 | 说明 |
---|---|---|
customEmails |
string[] |
要通知警报激活的管理员自定义电子邮件地址的列表。 |
odata.type |
string:
Microsoft. |
指定操作的类型。 有两种类型的操作:RuleEmailAction 和 RuleWebhookAction。 |
sendToServiceOwners |
boolean |
服务管理员(服务和协同管理员)在警报激活后是否应获得通知。 |
RuleManagementEventClaimsDataSource
规则管理事件数据源的声明。
名称 | 类型 | 说明 |
---|---|---|
emailAddress |
string |
电子邮件地址。 |
RuleManagementEventDataSource
规则管理事件数据源。 在这种情况下,鉴别器字段始终为 RuleManagementEventDataSource。
名称 | 类型 | 说明 |
---|---|---|
claims |
声明。 |
|
eventName |
string |
事件名称。 |
eventSource |
string |
事件源。 |
legacyResourceId |
string |
规则监视的资源的旧资源标识符。 注意:无法为现有规则更新此属性。 |
level |
string |
级别。 |
metricNamespace |
string |
指标的命名空间。 |
odata.type |
string:
Microsoft. |
指定数据源的类型。 有两种类型的规则数据源:RuleMetricDataSource 和 RuleManagementEventDataSource |
operationName |
string |
应该检查的操作的名称。 如果未提供任何名称,则任何操作都将匹配。 |
resourceGroupName |
string |
资源组名称。 |
resourceLocation |
string |
资源的位置。 |
resourceProviderName |
string |
资源提供程序名称。 |
resourceUri |
string |
规则监视的资源的资源标识符。 注意:无法为现有规则更新此属性。 |
status |
string |
应该检查的操作的状态。 如果未提供状态,则任何状态都将匹配。 |
subStatus |
string |
子状态。 |
RuleMetricDataSource
规则指标数据源。 在这种情况下,鉴别器值始终为 RuleMetricDataSource。
名称 | 类型 | 说明 |
---|---|---|
legacyResourceId |
string |
规则监视的资源的旧资源标识符。 注意:无法为现有规则更新此属性。 |
metricName |
string |
定义规则监视的指标的名称。 |
metricNamespace |
string |
指标的命名空间。 |
odata.type |
string:
Microsoft. |
指定数据源的类型。 有两种类型的规则数据源:RuleMetricDataSource 和 RuleManagementEventDataSource |
resourceLocation |
string |
资源的位置。 |
resourceUri |
string |
规则监视的资源的资源标识符。 注意:无法为现有规则更新此属性。 |
RuleWebhookAction
指定在计算规则条件时要发布到服务的操作。 在这种情况下,鉴别器始终为 RuleWebhookAction。
名称 | 类型 | 说明 |
---|---|---|
odata.type |
string:
Microsoft. |
指定操作的类型。 有两种类型的操作:RuleEmailAction 和 RuleWebhookAction。 |
properties |
object |
要包含在后期操作中的自定义属性的字典。 这些数据将追加到 Webhook 有效负载。 |
serviceUri |
string |
服务 URI,用于在警报激活或解决时发布通知。 |
ThresholdRuleCondition
基于越过阈值的指标的规则条件。
名称 | 类型 | 说明 |
---|---|---|
dataSource | RuleDataSource: |
规则从中收集数据的资源。 对于此类型,dataSource 将始终为 RuleMetricDataSource 类型。 |
odata.type |
string:
Microsoft. |
指定条件的类型。 这可以是以下三种类型之一:ManagementEventRuleCondition (管理事件) 、LocationThresholdRuleCondition ((基于 Web 测试) 的失败次数)和 ThresholdRuleCondition (基于指标) 的阈值。 |
operator |
用于比较数据和阈值的运算符。 |
|
threshold |
number |
激活警报的阈值。 |
timeAggregation |
时间聚合运算符。 收集的数据应如何随着时间推移而合并。 默认值为 Metric 的 PrimaryAggregationType。 |
|
windowSize |
string |
iso 8601 持续时间格式 (的时间段) ,用于根据阈值监视警报活动。 如果指定,则它必须介于 5 分钟到 1 天之间。 |
TimeAggregationOperator
规则中允许的聚合运算符。
名称 | 类型 | 说明 |
---|---|---|
Average |
string |
|
Last |
string |
|
Maximum |
string |
|
Minimum |
string |
|
Total |
string |