共用方式為


Metric Alerts - Create Or Update

建立或更新計量警示定義。

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}?api-version=2018-03-01

URI 參數

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

string

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

ruleName
path True

string

規則的名稱。

subscriptionId
path True

string

目標訂用帳戶的標識碼。

api-version
query True

string

用於此作業的 API 版本。

要求本文

名稱 必要 類型 Description
location True

string

資源位置

properties.criteria True MetricAlertCriteria:

定義特定的警示準則資訊。

properties.enabled True

boolean

指出是否啟用計量警示的旗標。

properties.evaluationFrequency True

string

以 ISO 8601 持續時間格式來評估計量警示的頻率。

properties.scopes True

string[]

此計量警示的範圍為的資源標識符清單。

properties.severity True

integer

警示嚴重性 {0, 1, 2, 3, 4}

properties.windowSize True

string

ISO 8601 持續時間格式 (期間) ,用來根據閾值監視警示活動。

properties.actions

MetricAlertAction[]

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

properties.autoMitigate

boolean

指出是否應該自動解決警示的旗標。 預設值是 true。

properties.description

string

將包含在警示電子郵件中的計量警示描述。

properties.targetResourceRegion

string

建立/更新警示的目標資源 () 區域。 如果範圍包含訂用帳戶、資源群組或多個資源,則為必要。

properties.targetResourceType

string

建立/更新警示的目標資源 () 的資源類型。 如果範圍包含訂用帳戶、資源群組或多個資源,則為必要。

tags

object

資源標籤

回應

名稱 類型 Description
200 OK

MetricAlertResource

確定

Other Status Codes

ErrorResponse

BadRequest

安全性

azure_auth

Azure Active Directory OAuth2 Flow

類型: oauth2
Flow: implicit
授權 URL: https://login.microsoftonline.com/common/oauth2/authorize

範圍

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

範例

Create or update a dynamic alert rule for Multiple Resources
Create or update a dynamic alert rule for Single Resource
Create or update a web test alert rule
Create or update an alert rule for Multiple Resource
Create or update an alert rule for Single Resource
Create or update an alert rule on Resource group(s)
Create or update an alert rule on Subscription
Create or update an alert rules with dimensions

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"
        }
      }
    ]
  }
}

定義

名稱 Description
AggregationTypeEnum

準則時間匯總類型。

DynamicMetricCriteria

動態閾值的準則。

DynamicThresholdFailingPeriods

引發警示所需的所選回溯時間範圍內所需的違規數目下限。

DynamicThresholdOperator

用來比較計量值與臨界值的運算子。

DynamicThresholdSensitivity

觸發警示所需的偏差範圍。 這會影響臨界值與計量系列模式的緊密程度。

ErrorResponse

描述錯誤回應的格式。

MetricAlertAction

警示動作。

MetricAlertMultipleResourceMultipleMetricCriteria

指定具有多個計量準則之多個資源的計量警示準則。

MetricAlertResource

計量警示資源。

MetricAlertSingleResourceMultipleMetricCriteria

指定具有多個計量準則之單一資源的計量警示準則。

MetricCriteria

篩選計量的準則。

MetricDimension

指定計量維度。

Operator

criteria 運算子。

WebtestLocationAvailabilityCriteria

指定 Web 測試資源的計量警示規則準則。

AggregationTypeEnum

準則時間匯總類型。

名稱 類型 Description
Average

string

Count

string

Maximum

string

Minimum

string

Total

string

DynamicMetricCriteria

動態閾值的準則。

名稱 類型 Description
alertSensitivity

DynamicThresholdSensitivity

觸發警示所需的偏差範圍。 這會影響臨界值與計量系列模式的緊密程度。

criterionType string:

DynamicThresholdCriterion

指定臨界值準則的類型

dimensions

MetricDimension[]

維度條件的清單。

failingPeriods

DynamicThresholdFailingPeriods

引發警示所需的所選回溯時間範圍內所需的違規數目下限。

ignoreDataBefore

string

使用此選項可設定開始學習計量歷程記錄數據的日期,並以ISO8601格式計算動態閾值 ()

metricName

string

計量的名稱。

metricNamespace

string

計量的命名空間。

name

string

準則的名稱。

operator

DynamicThresholdOperator

用來比較計量值與臨界值的運算子。

skipMetricValidation

boolean

藉由導致略過計量驗證,允許針對尚未發出的自訂計量建立警示規則。

timeAggregation

AggregationTypeEnum

準則時間匯總類型。

DynamicThresholdFailingPeriods

引發警示所需的所選回溯時間範圍內所需的違規數目下限。

名稱 類型 Description
minFailingPeriodsToAlert

number

觸發警示的違規次數。 應小於或等於 numberOfEvaluationPeriods。

numberOfEvaluationPeriods

number

匯總回溯點的數目。 回溯時間範圍是根據匯總數據粒度計算, (windowSize) 和選取的匯總點數目。

DynamicThresholdOperator

用來比較計量值與臨界值的運算子。

名稱 類型 Description
GreaterOrLessThan

string

GreaterThan

string

LessThan

string

DynamicThresholdSensitivity

觸發警示所需的偏差範圍。 這會影響臨界值與計量系列模式的緊密程度。

名稱 類型 Description
High

string

Low

string

Medium

string

ErrorResponse

描述錯誤回應的格式。

名稱 類型 Description
code

string

錯誤碼

message

string

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

MetricAlertAction

警示動作。

名稱 類型 Description
actionGroupId

string

要使用的動作群組標識碼。

webHookProperties

object

此欄位允許指定自定義屬性,這會附加至傳送為 Webhook 輸入的警示承載。

MetricAlertMultipleResourceMultipleMetricCriteria

指定具有多個計量準則之多個資源的計量警示準則。

名稱 類型 Description
allOf MultiMetricCriteria[]:

此「全部」作業的多個計量準則清單。

odata.type string:

Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria

指定警示準則的類型。

MetricAlertResource

計量警示資源。

名稱 類型 Description
id

string

Azure 資源標識碼

location

string

資源位置

name

string

Azure 資源名稱

properties.actions

MetricAlertAction[]

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

properties.autoMitigate

boolean

指出是否應該自動解決警示的旗標。 預設值是 true。

properties.criteria MetricAlertCriteria:

定義特定的警示準則資訊。

properties.description

string

將包含在警示電子郵件中的計量警示描述。

properties.enabled

boolean

指出是否啟用計量警示的旗標。

properties.evaluationFrequency

string

以 ISO 8601 持續時間格式來評估計量警示的頻率。

properties.isMigrated

boolean

值,指出是否已移轉此警示規則。

properties.lastUpdatedTime

string

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

properties.scopes

string[]

此計量警示的範圍為的資源標識符清單。

properties.severity

integer

警示嚴重性 {0, 1, 2, 3, 4}

properties.targetResourceRegion

string

建立/更新警示的目標資源 () 區域。 如果範圍包含訂用帳戶、資源群組或多個資源,則為必要。

properties.targetResourceType

string

建立/更新警示的目標資源 () 的資源類型。 如果範圍包含訂用帳戶、資源群組或多個資源,則為必要。

properties.windowSize

string

ISO 8601 持續時間格式 (期間) ,用來根據閾值監視警示活動。

tags

object

資源標籤

type

string

Azure 資源類型

MetricAlertSingleResourceMultipleMetricCriteria

指定具有多個計量準則之單一資源的計量警示準則。

名稱 類型 Description
allOf

MetricCriteria[]

此「全部」作業的計量準則清單。

odata.type string:

Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria

指定警示準則的類型。

MetricCriteria

篩選計量的準則。

名稱 類型 Description
criterionType string:

StaticThresholdCriterion

指定臨界值準則的類型

dimensions

MetricDimension[]

維度條件的清單。

metricName

string

計量的名稱。

metricNamespace

string

計量的命名空間。

name

string

準則的名稱。

operator

Operator

criteria 運算子。

skipMetricValidation

boolean

藉由導致略過計量驗證,允許針對尚未發出的自訂計量建立警示規則。

threshold

number

啟動警示的準則臨界值。

timeAggregation

AggregationTypeEnum

準則時間匯總類型。

MetricDimension

指定計量維度。

名稱 類型 Description
name

string

維度的名稱。

operator

string

維度運算子。 僅支援 'Include' 和 'Exclude'

values

string[]

維度值的清單。

Operator

criteria 運算子。

名稱 類型 Description
Equals

string

GreaterThan

string

GreaterThanOrEqual

string

LessThan

string

LessThanOrEqual

string

WebtestLocationAvailabilityCriteria

指定 Web 測試資源的計量警示規則準則。

名稱 類型 Description
componentId

string

Application Insights 資源標識符。

failedLocationCount

number

失敗的位置數目。

odata.type string:

Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria

指定警示準則的類型。

webTestId

string

Application Insights Web 測試標識符。