Metric Alerts - Create Or Update
创建或更新指标警报定义。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}?api-version=2018-03-01URI 参数
| 名称 | 在 | 必需 | 类型 | 说明 | 
|---|---|---|---|---|
| resource | path | True | stringminLength: 1 maxLength: 90 | 资源组的名称。 名称不区分大小写。 | 
| rule | path | True | string | 规则的名称。 | 
| subscription | path | True | stringminLength: 1 | 目标订阅的 ID。 | 
| api-version | query | True | stringminLength: 1 | 用于此操作的 API 版本。 | 
请求正文
| 名称 | 必需 | 类型 | 说明 | 
|---|---|---|---|
| location | True | string | 资源位置 | 
| properties.criteria | True | MetricAlertCriteria: | 定义特定的警报条件信息。 | 
| properties.enabled | True | boolean | 指示是否启用指标警报的标志。 | 
| properties.evaluationFrequency | True | string (duration) | 以 ISO 8601 持续时间格式计算指标警报的频率。 | 
| properties.scopes | True | string[] | 资源 ID 的列表是此指标警报的范围。 不能根据日志更改指标规则的范围。 | 
| properties.severity | True | integer (int32) | 警报严重性 {0, 1, 2, 3, 4} | 
| properties.windowSize | True | string (duration) | 用于基于阈值监视警报活动的时间段(采用 ISO 8601 持续时间格式)。 | 
| properties.actions | 警报规则处于活动状态以及解决警报条件时执行的操作数组。 | ||
| properties.autoMitigate | boolean | 指示是否应自动解决警报的标志。 默认值为 true。 | |
| properties.description | string | 警报电子邮件中包含的指标警报的说明。 | |
| properties.targetResourceRegion | string | 创建/更新警报的目标资源的区域。 如果范围包含订阅、资源组或多个资源,则是必需的。 | |
| properties.targetResourceType | string | 创建/更新警报的目标资源的资源类型。 如果范围包含订阅、资源组或多个资源,则是必需的。 | |
| tags | object | 资源标记 | 
响应
| 名称 | 类型 | 说明 | 
|---|---|---|
| 200 OK | 还行 | |
| Other Status Codes | 错误请求 | 
安全性
azure_auth
Azure Active Directory OAuth2 流
					类型: 
					oauth2
					流向: 
					implicit
					授权 URL: 
					https://login.microsoftonline.com/common/oauth2/authorize
			
作用域
| 名称 | 说明 | 
|---|---|
| user_impersonation | 模拟用户帐户 | 
示例
Create or update a dynamic alert rule for Multiple Resources
示例请求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/MetricAlertOnMultipleResources?api-version=2018-03-01
{
  "location": "global",
  "tags": {},
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
      "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "targetResourceType": "Microsoft.Compute/virtualMachines",
    "targetResourceRegion": "southcentralus",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "DynamicThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "Percentage CPU",
          "metricNamespace": "microsoft.compute/virtualmachines",
          "operator": "GreaterOrLessThan",
          "timeAggregation": "Average",
          "dimensions": [],
          "alertSensitivity": "Medium",
          "failingPeriods": {
            "numberOfEvaluationPeriods": 4,
            "minFailingPeriodsToAlert": 4
          }
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}
示例响应
{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertOnMultipleResources",
  "type": "Microsoft.Insights/metricAlerts",
  "location": "global",
  "tags": {
    "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
  },
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
      "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "targetResourceType": "Microsoft.Compute/virtualMachines",
    "targetResourceRegion": "southcentralus",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "DynamicThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "Percentage CPU",
          "metricNamespace": "microsoft.compute/virtualmachines",
          "operator": "GreaterOrLessThan",
          "timeAggregation": "Average",
          "dimensions": [],
          "alertSensitivity": "Medium",
          "failingPeriods": {
            "numberOfEvaluationPeriods": 4,
            "minFailingPeriodsToAlert": 4
          }
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}Create or update a dynamic alert rule for Single Resource
示例请求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/chiricutin?api-version=2018-03-01
{
  "location": "global",
  "tags": {},
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "DynamicThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "Percentage CPU",
          "metricNamespace": "microsoft.compute/virtualmachines",
          "operator": "GreaterOrLessThan",
          "timeAggregation": "Average",
          "dimensions": [],
          "alertSensitivity": "Medium",
          "failingPeriods": {
            "numberOfEvaluationPeriods": 4,
            "minFailingPeriodsToAlert": 4
          },
          "ignoreDataBefore": "2019-04-04T21:00:00.000Z"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}
示例响应
{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin",
  "type": "Microsoft.Insights/metricAlerts",
  "location": "global",
  "tags": {
    "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
  },
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "targetResourceType": "Microsoft.Compute/virtualMachines",
    "targetResourceRegion": "southcentralus",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "DynamicThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "Percentage CPU",
          "metricNamespace": "microsoft.compute/virtualmachines",
          "operator": "GreaterOrLessThan",
          "timeAggregation": "Average",
          "dimensions": [],
          "alertSensitivity": "Medium",
          "failingPeriods": {
            "numberOfEvaluationPeriods": 4,
            "minFailingPeriodsToAlert": 4
          },
          "ignoreDataBefore": "2019-04-04T21:00:00.000Z"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}Create or update a web test alert rule
示例请求
PUT https://management.azure.com/subscriptions/12345678-1234-1234-1234-123456789101/resourceGroups/rg-example/providers/Microsoft.Insights/metricAlerts/webtest-name-example?api-version=2018-03-01
{
  "location": "global",
  "tags": {
    "hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example": "Resource",
    "hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example": "Resource"
  },
  "properties": {
    "description": "Automatically created alert rule for availability test \"component-example\" a",
    "enabled": true,
    "severity": 4,
    "windowSize": "PT15M",
    "evaluationFrequency": "PT1M",
    "criteria": {
      "failedLocationCount": 2,
      "webTestId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example",
      "componentId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example",
      "odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria"
    },
    "actions": [],
    "scopes": [
      "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example",
      "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example"
    ]
  }
}
示例响应
{
  "location": "global",
  "type": "Microsoft.Insights/metricAlerts",
  "name": "webtest-name-example",
  "id": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/metricalerts/webtest-name-example",
  "tags": {
    "hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/component-example": "Resource",
    "hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/webtest-name-example": "Resource"
  },
  "properties": {
    "description": "Automatically created alert rule for availability test \"webtest-name-example\" a",
    "severity": 4,
    "enabled": true,
    "scopes": [
      "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/webtest-name-example",
      "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/component-example"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "criteria": {
      "webTestId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/webtest-name-example",
      "componentId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/component-example",
      "failedLocationCount": 2,
      "odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria"
    },
    "actions": []
  }
}Create or update an alert rule for Multiple Resource
示例请求
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/MetricAlertOnMultipleResources?api-version=2018-03-01
{
  "location": "global",
  "tags": {},
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "targetResourceType": "Microsoft.Compute/virtualMachines",
    "targetResourceRegion": "southcentralus",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "StaticThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "Percentage CPU",
          "metricNamespace": "microsoft.compute/virtualmachines",
          "dimensions": [],
          "operator": "GreaterThan",
          "threshold": 80.5,
          "timeAggregation": "Average"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}
示例响应
{
  "id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertOnMultipleResources",
  "type": "Microsoft.Insights/metricAlerts",
  "location": "global",
  "tags": {
    "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
  },
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "targetResourceType": "Microsoft.Compute/virtualMachines",
    "targetResourceRegion": "southcentralus",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "StaticThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "Percentage CPU",
          "metricNamespace": "microsoft.compute/virtualmachines",
          "dimensions": [],
          "operator": "GreaterThan",
          "threshold": 80.5,
          "timeAggregation": "Average"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}Create or update an alert rule for Single Resource
示例请求
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/chiricutin?api-version=2018-03-01
{
  "location": "global",
  "tags": {},
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "StaticThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "\\Processor(_Total)\\% Processor Time",
          "dimensions": [],
          "operator": "GreaterThan",
          "threshold": 80.5,
          "timeAggregation": "Average"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}
示例响应
{
  "id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin",
  "type": "Microsoft.Insights/metricAlerts",
  "location": "global",
  "tags": {
    "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
  },
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "StaticThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "\\Processor(_Total)\\% Processor Time",
          "dimensions": [],
          "operator": "GreaterThan",
          "threshold": 80.5,
          "timeAggregation": "Average"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}Create or update an alert rule on Resource group(s)
示例请求
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1/providers/Microsoft.Insights/metricAlerts/MetricAlertAtResourceGroupLevel?api-version=2018-03-01
{
  "location": "global",
  "tags": {},
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1",
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest2"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "targetResourceType": "Microsoft.Compute/virtualMachines",
    "targetResourceRegion": "southcentralus",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "StaticThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "Percentage CPU",
          "metricNamespace": "microsoft.compute/virtualmachines",
          "dimensions": [],
          "operator": "GreaterThan",
          "threshold": 80.5,
          "timeAggregation": "Average"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}
示例响应
{
  "id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1/providers/providers/microsoft.insights/metricalerts/MetricAlertAtResourceGroupLevel",
  "type": "Microsoft.Insights/metricAlerts",
  "location": "global",
  "tags": {
    "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
  },
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1",
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest2"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "targetResourceType": "Microsoft.Compute/virtualMachines",
    "targetResourceRegion": "southcentralus",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "StaticThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "Percentage CPU",
          "metricNamespace": "microsoft.compute/virtualmachines",
          "dimensions": [],
          "operator": "GreaterThan",
          "threshold": 80.5,
          "timeAggregation": "Average"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}Create or update an alert rule on Subscription
示例请求
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/MetricAlertAtSubscriptionLevel?api-version=2018-03-01
{
  "location": "global",
  "tags": {},
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "targetResourceType": "Microsoft.Compute/virtualMachines",
    "targetResourceRegion": "southcentralus",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "StaticThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "Percentage CPU",
          "metricNamespace": "microsoft.compute/virtualmachines",
          "dimensions": [],
          "operator": "GreaterThan",
          "threshold": 80.5,
          "timeAggregation": "Average"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}
示例响应
{
  "id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertAtSubscriptionLevel",
  "type": "Microsoft.Insights/metricAlerts",
  "location": "global",
  "tags": {
    "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
  },
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"
    ],
    "evaluationFrequency": "PT1M",
    "windowSize": "PT15M",
    "targetResourceType": "Microsoft.Compute/virtualMachines",
    "targetResourceRegion": "southcentralus",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "criterionType": "StaticThresholdCriterion",
          "name": "High_CPU_80",
          "metricName": "Percentage CPU",
          "metricNamespace": "microsoft.compute/virtualmachines",
          "dimensions": [],
          "operator": "GreaterThan",
          "threshold": 80.5,
          "timeAggregation": "Average"
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}Create or update an alert rules with dimensions
示例请求
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/MetricAlertOnMultipleDimensions?api-version=2018-03-01
{
  "location": "global",
  "tags": {},
  "properties": {
    "description": "This is the description of the rule1",
    "enabled": true,
    "severity": 3,
    "windowSize": "P1D",
    "evaluationFrequency": "PT1H",
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.KeyVault/vaults/keyVaultResource"
    ],
    "criteria": {
      "allOf": [
        {
          "metricName": "Availability",
          "metricNamespace": "Microsoft.KeyVault/vaults",
          "operator": "GreaterThan",
          "timeAggregation": "Average",
          "name": "Metric1",
          "dimensions": [
            {
              "name": "ActivityName",
              "operator": "Include",
              "values": [
                "*"
              ]
            },
            {
              "name": "StatusCode",
              "operator": "Include",
              "values": [
                "200"
              ]
            }
          ],
          "criterionType": "StaticThresholdCriterion",
          "threshold": 55
        }
      ],
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
    },
    "actions": [
      {
        "actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ],
    "autoMitigate": true
  }
}
示例响应
{
  "id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertWithDimensions",
  "type": "Microsoft.Insights/metricAlerts",
  "location": "global",
  "tags": {
    "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
  },
  "properties": {
    "description": "This is the description of the rule1",
    "severity": 3,
    "enabled": true,
    "scopes": [
      "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.KeyVault/vaults/keyVaultResource"
    ],
    "evaluationFrequency": "PT1H",
    "windowSize": "P1D",
    "targetResourceType": "Microsoft.KeyVault/vaults",
    "targetResourceRegion": "southcentralus",
    "criteria": {
      "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
      "allOf": [
        {
          "metricName": "Availability",
          "metricNamespace": "Microsoft.KeyVault/vaults",
          "operator": "GreaterThan",
          "timeAggregation": "Average",
          "name": "Metric1",
          "dimensions": [
            {
              "name": "ActivityName",
              "operator": "Include",
              "values": [
                "*"
              ]
            },
            {
              "name": "StatusCode",
              "operator": "Include",
              "values": [
                "200"
              ]
            }
          ],
          "criterionType": "StaticThresholdCriterion",
          "threshold": 55
        }
      ]
    },
    "autoMitigate": true,
    "actions": [
      {
        "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
        "webHookProperties": {
          "key11": "value11",
          "key12": "value12"
        }
      }
    ]
  }
}定义
| 名称 | 说明 | 
|---|---|
| Additional | 具有“type”和“info”属性的对象数组。 “info”的架构特定于服务,依赖于“type”字符串。 | 
| Aggregation | 条件时间聚合类型。 | 
| Dynamic | 动态阈值的条件。 | 
| Dynamic | 在引发警报所需的所选回溯时间范围内所需的最小冲突数。 | 
| Dynamic | 用于将指标值与阈值进行比较的运算符。 | 
| Dynamic | 触发警报所需的偏差范围。 这会影响阈值对指标系列模式的严格程度。 | 
| Error | |
| Error | 描述错误响应的详细信息。 | 
| Error | 描述错误响应的格式。 | 
| Metric | 警报操作。 | 
| Metric | 为具有多个指标条件的多个资源指定指标警报条件。 | 
| Metric | 指标警报资源。 | 
| Metric | 为具有多个指标条件的单个资源指定指标警报条件。 | 
| Metric | 筛选指标的条件。 | 
| Metric | 指定指标维度。 | 
| Operator | 条件运算符。 | 
| Webtest | 指定 Web 测试资源的指标警报规则条件。 | 
AdditionalInfo 
			
			具有“type”和“info”属性的对象数组。 “info”的架构特定于服务,依赖于“type”字符串。
| 名称 | 类型 | 说明 | 
|---|---|---|
| info | 特定于类型的其他信息。 | |
| type | string | 其他信息的类型。 | 
AggregationTypeEnum  
			
			条件时间聚合类型。
| 值 | 说明 | 
|---|---|
| Average | |
| Count | |
| Minimum | |
| Maximum | |
| Total | 
DynamicMetricCriteria  
			
			动态阈值的条件。
| 名称 | 类型 | 说明 | 
|---|---|---|
| alertSensitivity | 触发警报所需的偏差范围。 这会影响阈值对指标系列模式的严格程度。 | |
| criterionType | string: 
					Dynamic | 指定阈值条件的类型 | 
| dimensions | 维度条件列表。 | |
| failingPeriods | 在引发警报所需的所选回溯时间范围内所需的最小冲突数。 | |
| ignoreDataBefore | string (date-time) | 使用此选项可设置开始学习指标历史数据的日期并计算动态阈值(ISO8601格式) | 
| metricName | string | 指标的名称。 | 
| metricNamespace | string | 指标的命名空间。 | 
| name | string | 条件的名称。 | 
| operator | 用于将指标值与阈值进行比较的运算符。 | |
| skipMetricValidation | boolean | 允许针对尚未发出的自定义指标创建警报规则,方法是跳过指标验证。 | 
| timeAggregation | 条件时间聚合类型。 | 
DynamicThresholdFailingPeriods   
			
			在引发警报所需的所选回溯时间范围内所需的最小冲突数。
| 名称 | 类型 | 说明 | 
|---|---|---|
| minFailingPeriodsToAlert | number | 触发警报的冲突数。 应小于或等于 numberOfEvaluationPeriods。 | 
| numberOfEvaluationPeriods | number | 聚合回溯点数。 回溯时间窗口是根据聚合粒度(windowSize)和所选聚合点数计算的。 | 
DynamicThresholdOperator  
			
			用于将指标值与阈值进行比较的运算符。
| 值 | 说明 | 
|---|---|
| GreaterThan | |
| LessThan | |
| GreaterOrLessThan | 
DynamicThresholdSensitivity  
			
			触发警报所需的偏差范围。 这会影响阈值对指标系列模式的严格程度。
| 值 | 说明 | 
|---|---|
| Low | |
| Medium | |
| High | 
Error
| 名称 | 类型 | 说明 | 
|---|---|---|
| additionalInfo | 具有“type”和“info”属性的对象数组。 “info”的架构特定于服务,依赖于“type”字符串。 | |
| code | string | 可用于以编程方式标识错误的未分配字符串。 | 
| details | 其他嵌套错误响应信息对象数组,如此协定所述。 | |
| message | string | 详细描述错误并提供调试信息。 如果在请求中设置了 Accept-Language,则必须将其本地化为该语言。 | 
| target | string | 特定错误的目标(例如,错误中属性的名称)。 | 
ErrorDetail 
			
			描述错误响应的详细信息。
| 名称 | 类型 | 说明 | 
|---|---|---|
| additionalInfo | 具有“type”和“info”属性的对象数组。 “info”的架构特定于服务,依赖于“type”字符串。 | |
| code | string | 可用于以编程方式标识错误的未分配字符串。 | 
| message | string | 详细描述错误并提供调试信息。 | 
| target | string | 特定错误的目标(例如,错误中属性的名称)。 | 
ErrorResponse 
			
			描述错误响应的格式。
| 名称 | 类型 | 说明 | 
|---|---|---|
| error | 
MetricAlertAction  
			
			警报操作。
| 名称 | 类型 | 说明 | 
|---|---|---|
| actionGroupId | string | 要使用的操作组的 ID。 | 
| webHookProperties | object | 此字段允许指定自定义属性,这些属性将追加到作为输入发送到 Webhook 的警报有效负载中。 | 
MetricAlertMultipleResourceMultipleMetricCriteria      
			
			为具有多个指标条件的多个资源指定指标警报条件。
| 名称 | 类型 | 说明 | 
|---|---|---|
| allOf | MultiMetricCriteria[]: | 此“全部”操作的多个指标条件的列表。 | 
| odata.type | string: 
					Microsoft. | 指定警报条件的类型。 | 
MetricAlertResource  
			
			指标警报资源。
| 名称 | 类型 | 说明 | 
|---|---|---|
| id | string | Azure 资源 ID | 
| location | string | 资源位置 | 
| name | string | Azure 资源名称 | 
| properties.actions | 警报规则处于活动状态以及解决警报条件时执行的操作数组。 | |
| properties.autoMitigate | boolean | 指示是否应自动解决警报的标志。 默认值为 true。 | 
| properties.criteria | MetricAlertCriteria: | 定义特定的警报条件信息。 | 
| properties.description | string | 警报电子邮件中包含的指标警报的说明。 | 
| properties.enabled | boolean | 指示是否启用指标警报的标志。 | 
| properties.evaluationFrequency | string (duration) | 以 ISO 8601 持续时间格式计算指标警报的频率。 | 
| properties.isMigrated | boolean | 指示是否迁移此警报规则的值。 | 
| properties.lastUpdatedTime | string (date-time) | 上次以ISO8601格式更新规则的时间。 | 
| properties.scopes | string[] | 资源 ID 的列表是此指标警报的范围。 不能根据日志更改指标规则的范围。 | 
| properties.severity | integer (int32) | 警报严重性 {0, 1, 2, 3, 4} | 
| properties.targetResourceRegion | string | 创建/更新警报的目标资源的区域。 如果范围包含订阅、资源组或多个资源,则是必需的。 | 
| properties.targetResourceType | string | 创建/更新警报的目标资源的资源类型。 如果范围包含订阅、资源组或多个资源,则是必需的。 | 
| properties.windowSize | string (duration) | 用于基于阈值监视警报活动的时间段(采用 ISO 8601 持续时间格式)。 | 
| tags | object | 资源标记 | 
| type | string | Azure 资源类型 | 
MetricAlertSingleResourceMultipleMetricCriteria      
			
			为具有多个指标条件的单个资源指定指标警报条件。
| 名称 | 类型 | 说明 | 
|---|---|---|
| allOf | 此“全部”操作的指标条件列表。 | |
| odata.type | string: 
					Microsoft. | 指定警报条件的类型。 | 
MetricCriteria 
			
			筛选指标的条件。
| 名称 | 类型 | 说明 | 
|---|---|---|
| criterionType | string: 
					Static | 指定阈值条件的类型 | 
| dimensions | 维度条件列表。 | |
| metricName | string | 指标的名称。 | 
| metricNamespace | string | 指标的命名空间。 | 
| name | string | 条件的名称。 | 
| operator | 条件运算符。 | |
| skipMetricValidation | boolean | 允许针对尚未发出的自定义指标创建警报规则,方法是跳过指标验证。 | 
| threshold | number (double) | 激活警报的条件阈值。 | 
| timeAggregation | 条件时间聚合类型。 | 
MetricDimension 
			
			指定指标维度。
| 名称 | 类型 | 说明 | 
|---|---|---|
| name | string | 维度的名称。 | 
| operator | string | 维度运算符。 仅支持“Include”和“Exclude” | 
| values | string[] | 维度值列表。 | 
Operator
条件运算符。
| 值 | 说明 | 
|---|---|
| Equals | |
| GreaterThan | |
| GreaterThanOrEqual | |
| LessThan | |
| LessThanOrEqual | 
WebtestLocationAvailabilityCriteria   
			
			指定 Web 测试资源的指标警报规则条件。
| 名称 | 类型 | 说明 | 
|---|---|---|
| componentId | string | Application Insights 资源 ID。 | 
| failedLocationCount | number | 失败的位置数。 | 
| odata.type | string: 
					Microsoft. | 指定警报条件的类型。 | 
| webTestId | string | Application Insights Web 测试 ID。 |