Share via


Activity Log Alerts - Create Or Update

新しいアクティビティ ログ アラート ルールを作成するか、既存のルールを更新します。

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}?api-version=2020-10-01

URI パラメーター

名前 / 必須 説明
activityLogAlertName
path True

string

アクティビティ ログ アラート ルールの名前。

resourceGroupName
path True

string

リソース グループの名前。 名前の大文字と小文字は区別されます。

subscriptionId
path True

string

ターゲット サブスクリプションの ID。

api-version
query True

string

この操作に使用する API バージョン。

要求本文

名前 必須 説明
properties.actions True

ActionList

条件が満たされたときにアクティブになるアクション。

properties.condition True

AlertRuleAllOfCondition

このアラートをアクティブにする条件。

properties.scopes True

string[]

プレフィックスとして使用されるリソース ID の一覧。 アラートは、これらのプレフィックスのいずれかに該当するリソース ID を持つアクティビティ ログ イベントにのみ適用されます。 このリストには、少なくとも 1 つの項目が含まれている必要があります。

location

string

リソースの場所。 Azure アクティビティ ログ アラート ルールは、グローバル、西ヨーロッパ、北ヨーロッパのリージョンでサポートされています。

properties.description

string

このアクティビティ ログ アラート ルールの説明。

properties.enabled

boolean

このアクティビティ ログ アラート ルールが有効かどうかを示します。 アクティビティ ログ アラート ルールが有効になっていない場合、そのアクションはアクティブになりません。

tags

object

リソースのタグ。

応答

名前 説明
200 OK

ActivityLogAlertResource

既存のアクティビティ ログ アラート ルールが正常に更新されました。

201 Created

ActivityLogAlertResource

新しいアクティビティ ログ アラート ルールが正常に作成されました。

Other Status Codes

ErrorResponse

エラーが発生し、アクティビティ ログ アラート ルールを作成または更新できませんでした。

セキュリティ

azure_auth

Azure Active Directory OAuth2 フロー

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

Scopes

名前 説明
user_impersonation ユーザー アカウントの借用

Create or update an Activity Log Alert rule
Create or update an Activity Log Alert rule with 'anyOf' condition
Create or update an Activity Log Alert rule with 'containsAny'

Create or update an Activity Log Alert rule

Sample Request

PUT https://management.azure.com/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/activityLogAlerts/SampleActivityLogAlertRule?api-version=2020-10-01

{
  "location": "Global",
  "tags": {},
  "properties": {
    "scopes": [
      "/subscriptions/187f412d-1758-44d9-b052-169e2564721d"
    ],
    "condition": {
      "allOf": [
        {
          "field": "category",
          "equals": "Administrative"
        },
        {
          "field": "level",
          "equals": "Error"
        }
      ]
    },
    "actions": {
      "actionGroups": [
        {
          "actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
          "webhookProperties": {
            "sampleWebhookProperty": "SamplePropertyValue"
          }
        }
      ]
    },
    "enabled": true,
    "description": "Description of sample Activity Log Alert rule."
  }
}

Sample Response

{
  "id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRule",
  "type": "Microsoft.Insights/ActivityLogAlerts",
  "name": "SampleActivityLogAlertRule",
  "location": "Global",
  "tags": {},
  "properties": {
    "scopes": [
      "subscriptions/187f412d-1758-44d9-b052-169e2564721d"
    ],
    "condition": {
      "allOf": [
        {
          "field": "Category",
          "equals": "Administrative"
        },
        {
          "field": "Level",
          "equals": "Error"
        }
      ]
    },
    "actions": {
      "actionGroups": [
        {
          "actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/actionGroups/SampleActionGroup",
          "webhookProperties": {
            "sampleWebhookProperty": "SamplePropertyValue"
          }
        }
      ]
    },
    "enabled": true,
    "description": "Description of sample Activity Log Alert rule."
  }
}
{
  "id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRule",
  "type": "Microsoft.Insights/ActivityLogAlerts",
  "name": "SampleActivityLogAlertRule",
  "location": "Global",
  "tags": {},
  "properties": {
    "scopes": [
      "subscriptions/187f412d-1758-44d9-b052-169e2564721d"
    ],
    "condition": {
      "allOf": [
        {
          "field": "Category",
          "equals": "Administrative"
        },
        {
          "field": "Level",
          "equals": "Error"
        }
      ]
    },
    "actions": {
      "actionGroups": [
        {
          "actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/actionGroups/SampleActionGroup",
          "webhookProperties": {
            "sampleWebhookProperty": "SamplePropertyValue"
          }
        }
      ]
    },
    "enabled": true,
    "description": "Description of sample Activity Log Alert rule."
  }
}

Create or update an Activity Log Alert rule with 'anyOf' condition

Sample Request

PUT https://management.azure.com/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/activityLogAlerts/SampleActivityLogAlertRuleWithAnyOfCondition?api-version=2020-10-01

{
  "location": "Global",
  "tags": {},
  "properties": {
    "scopes": [
      "subscriptions/187f412d-1758-44d9-b052-169e2564721d"
    ],
    "condition": {
      "allOf": [
        {
          "field": "category",
          "equals": "ServiceHealth"
        },
        {
          "anyOf": [
            {
              "field": "properties.incidentType",
              "equals": "Incident"
            },
            {
              "field": "properties.incidentType",
              "equals": "Maintenance"
            }
          ]
        }
      ]
    },
    "actions": {
      "actionGroups": [
        {
          "actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
          "webhookProperties": {
            "sampleWebhookProperty": "SamplePropertyValue"
          }
        }
      ]
    },
    "enabled": true,
    "description": "Description of sample Activity Log Alert rule with 'anyOf' condition."
  }
}

Sample Response

{
  "id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithAnyOfCondition",
  "type": "Microsoft.Insights/ActivityLogAlerts",
  "name": "SampleActivityLogAlertRuleWithAnyOfCondition",
  "location": "Global",
  "tags": {},
  "properties": {
    "scopes": [
      "subscriptions/187f412d-1758-44d9-b052-169e2564721d"
    ],
    "condition": {
      "allOf": [
        {
          "field": "category",
          "equals": "ServiceHealth"
        },
        {
          "anyOf": [
            {
              "field": "properties.incidentType",
              "equals": "Incident"
            },
            {
              "field": "properties.incidentType",
              "equals": "Maintenance"
            }
          ]
        }
      ]
    },
    "actions": {
      "actionGroups": [
        {
          "actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
          "webhookProperties": {
            "sampleWebhookProperty": "SamplePropertyValue"
          }
        }
      ]
    },
    "enabled": true,
    "description": "Description of sample Activity Log Alert rule with 'anyOf' condition."
  }
}
{
  "id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithAnyOfCondition",
  "type": "Microsoft.Insights/ActivityLogAlerts",
  "name": "SampleActivityLogAlertRuleWithAnyOfCondition",
  "location": "Global",
  "tags": {},
  "properties": {
    "scopes": [
      "subscriptions/187f412d-1758-44d9-b052-169e2564721d"
    ],
    "condition": {
      "allOf": [
        {
          "field": "category",
          "equals": "ServiceHealth"
        },
        {
          "anyOf": [
            {
              "field": "properties.incidentType",
              "equals": "Incident"
            },
            {
              "field": "properties.incidentType",
              "equals": "Maintenance"
            }
          ]
        }
      ]
    },
    "actions": {
      "actionGroups": [
        {
          "actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
          "webhookProperties": {
            "sampleWebhookProperty": "SamplePropertyValue"
          }
        }
      ]
    },
    "enabled": true,
    "description": "Description of sample Activity Log Alert rule with 'anyOf' condition."
  }
}

Create or update an Activity Log Alert rule with 'containsAny'

Sample Request

PUT https://management.azure.com/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/activityLogAlerts/SampleActivityLogAlertRuleWithContainsAny?api-version=2020-10-01

{
  "location": "Global",
  "tags": {},
  "properties": {
    "scopes": [
      "subscriptions/187f412d-1758-44d9-b052-169e2564721d"
    ],
    "condition": {
      "allOf": [
        {
          "field": "category",
          "equals": "ServiceHealth"
        },
        {
          "field": "properties.impactedServices[*].ImpactedRegions[*].RegionName",
          "containsAny": [
            "North Europe",
            "West Europe"
          ]
        }
      ]
    },
    "actions": {
      "actionGroups": [
        {
          "actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
          "webhookProperties": {
            "sampleWebhookProperty": "SamplePropertyValue"
          }
        }
      ]
    },
    "enabled": true,
    "description": "Description of sample Activity Log Alert rule with 'containsAny'."
  }
}

Sample Response

{
  "id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithContainsAny",
  "type": "Microsoft.Insights/ActivityLogAlerts",
  "name": "SampleActivityLogAlertRuleWithContainsAny",
  "location": "Global",
  "tags": {},
  "properties": {
    "scopes": [
      "subscriptions/187f412d-1758-44d9-b052-169e2564721d"
    ],
    "condition": {
      "allOf": [
        {
          "field": "category",
          "equals": "ServiceHealth"
        },
        {
          "field": "properties.impactedServices[*].ImpactedRegions[*].RegionName",
          "containsAny": [
            "North Europe",
            "West Europe"
          ]
        }
      ]
    },
    "actions": {
      "actionGroups": [
        {
          "actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
          "webhookProperties": {
            "sampleWebhookProperty": "SamplePropertyValue"
          }
        }
      ]
    },
    "enabled": true,
    "description": "Description of sample Activity Log Alert rule with 'containsAny'."
  }
}
{
  "id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithContainsAny",
  "type": "Microsoft.Insights/ActivityLogAlerts",
  "name": "SampleActivityLogAlertRuleWithContainsAny",
  "location": "Global",
  "tags": {},
  "properties": {
    "scopes": [
      "subscriptions/187f412d-1758-44d9-b052-169e2564721d"
    ],
    "condition": {
      "allOf": [
        {
          "field": "category",
          "equals": "ServiceHealth"
        },
        {
          "field": "properties.impactedServices[*].ImpactedRegions[*].RegionName",
          "containsAny": [
            "North Europe",
            "West Europe"
          ]
        }
      ]
    },
    "actions": {
      "actionGroups": [
        {
          "actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
          "webhookProperties": {
            "sampleWebhookProperty": "SamplePropertyValue"
          }
        }
      ]
    },
    "enabled": true,
    "description": "Description of sample Activity Log Alert rule with 'containsAny'."
  }
}

定義

名前 説明
ActionGroup

Azure アクション グループへのポインター。

ActionList

アクティビティ ログ アラート ルールのアクションの一覧。

ActivityLogAlertResource

アクティビティ ログ アラート ルール リソース。

AlertRuleAllOfCondition

すべてのメンバー条件が満たされたときに満たされるアクティビティ ログ アラート ルールの条件。

AlertRuleAnyOfOrLeafCondition

すべてのメンバー条件が満たされたときに満たされるアクティビティ ログ アラート ルールの条件。 各条件には、次のいずれかの型を指定できます。 重要: 各型には、プロパティの一意のサブセットがあります。 異なる型のプロパティは、1 つの条件に存在できません。

  • リーフ条件 - 'field' と 'equals' または 'containsAny' を含める必要があります。 リーフ条件で 'anyOf' を設定 しないでください
  • AnyOf 条件 - 'anyOf' (リーフ条件の配列) のみを 含める必要があります。 'field'、'equals'、および 'containsAny' は AnyOf 条件で設定 しないでください
AlertRuleLeafCondition

アクティビティ ログ イベントのフィールドと値を比較することによって満たされるアクティビティ ログ アラート ルールの条件。 この条件には 'field' と 'equals' または 'containsAny' を含める必要があります。

ErrorResponse

エラー応答。

ActionGroup

Azure アクション グループへのポインター。

名前 説明
actionGroupId

string

アクション グループのリソース ID。 null または空にすることはできません。

webhookProperties

object

post 操作に含めるカスタム プロパティのディクショナリ。 これらのデータは Webhook ペイロードに追加されます。

ActionList

アクティビティ ログ アラート ルールのアクションの一覧。

名前 説明
actionGroups

ActionGroup[]

アクション グループの一覧。

ActivityLogAlertResource

アクティビティ ログ アラート ルール リソース。

名前 既定値 説明
id

string

リソース ID。

location

string

global

リソースの場所。 Azure アクティビティ ログ アラート ルールは、グローバル、西ヨーロッパ、北ヨーロッパのリージョンでサポートされています。

name

string

リソースの名前。

properties.actions

ActionList

条件が満たされたときにアクティブになるアクション。

properties.condition

AlertRuleAllOfCondition

このアラートをアクティブにする条件。

properties.description

string

このアクティビティ ログ アラート ルールの説明。

properties.enabled

boolean

True

このアクティビティ ログ アラート ルールが有効かどうかを示します。 アクティビティ ログ アラート ルールが有効になっていない場合、そのアクションはアクティブになりません。

properties.scopes

string[]

プレフィックスとして使用されるリソース ID の一覧。 アラートは、これらのプレフィックスのいずれかに該当するリソース ID を持つアクティビティ ログ イベントにのみ適用されます。 このリストには、少なくとも 1 つの項目が含まれている必要があります。

tags

object

リソースのタグ。

type

string

リソースの型。

AlertRuleAllOfCondition

すべてのメンバー条件が満たされたときに満たされるアクティビティ ログ アラート ルールの条件。

名前 説明
allOf

AlertRuleAnyOfOrLeafCondition[]

アクティビティ ログ アラート ルールの条件の一覧。

AlertRuleAnyOfOrLeafCondition

すべてのメンバー条件が満たされたときに満たされるアクティビティ ログ アラート ルールの条件。 各条件には、次のいずれかの型を指定できます。 重要: 各型には、プロパティの一意のサブセットがあります。 異なる型のプロパティは、1 つの条件に存在できません。

  • リーフ条件 - 'field' と 'equals' または 'containsAny' を含める必要があります。 リーフ条件で 'anyOf' を設定 しないでください
  • AnyOf 条件 - 'anyOf' (リーフ条件の配列) のみを 含める必要があります。 'field'、'equals'、および 'containsAny' は AnyOf 条件で設定 しないでください
名前 説明
anyOf

AlertRuleLeafCondition[]

アクティビティ ログ アラート ルール 'anyOf' 条件。
少なくとも 1 つのメンバー リーフ条件が満たされたときに満たされるアクティビティ ログ アラート ルールの条件。

containsAny

string[]

イベントのフィールドの値は、条件が満たされているかどうかを判断するために、この配列内の値と比較されます (大文字と小文字は区別されません)。

equals

string

イベントのフィールドの値は、条件が満たされているかどうかを判断するために、この値 (大文字と小文字は区別されません) と比較されます。

field

string

この条件で調べるアクティビティ ログ イベントのフィールドの名前。 このフィールドで使用できる値は (大文字と小文字を区別しない): 'resourceId'、'category'、'caller'、'level'、'operationName'、'resourceGroup'、'resourceProvider'、'status'、'subStatus'、'resourceType'、または 'properties' で始まるもの。

AlertRuleLeafCondition

アクティビティ ログ イベントのフィールドと値を比較することによって満たされるアクティビティ ログ アラート ルールの条件。 この条件には 'field' と 'equals' または 'containsAny' を含める必要があります。

名前 説明
containsAny

string[]

イベントのフィールドの値は、条件が満たされているかどうかを判断するために、この配列内の値と比較されます (大文字と小文字は区別されません)。

equals

string

イベントのフィールドの値は、条件が満たされているかどうかを判断するために、この値 (大文字と小文字は区別されません) と比較されます。

field

string

この条件で調べるアクティビティ ログ イベントのフィールドの名前。 このフィールドで使用できる値は (大文字と小文字を区別しない): 'resourceId'、'category'、'caller'、'level'、'operationName'、'resourceGroup'、'resourceProvider'、'status'、'subStatus'、'resourceType'、または 'properties' で始まるもの。

ErrorResponse

エラー応答。

名前 説明
code

string

エラー コード。

message

string

操作が失敗した理由を示すエラー メッセージ。