Smart Detector Alert Rules - Create Or Update

Create or update a Smart Detector alert rule.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}?api-version=2019-06-01

URI Parameters

Name In Required Type Description
alertRuleName
path True

string

The name of the alert rule.

resourceGroupName
path True

string

The name of the resource group.

subscriptionId
path True

string

The ID of the target subscription.

api-version
query True

string

Client Api Version.

Request Body

Name Required Type Description
properties.actionGroups True

ActionGroupsInformation

The alert rule actions.

properties.detector True

Detector

The alert rule's detector.

properties.frequency True

string

The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes.

properties.scope True

string[]

The alert rule resources scope.

properties.severity True

Severity

The alert rule severity.

properties.state True

AlertRuleState

The alert rule state.

location

string

The resource location.

properties.description

string

The alert rule description.

properties.throttling

ThrottlingInformation

The alert rule throttling information.

tags

object

The resource tags.

Responses

Name Type Description
200 OK

AlertRule

Successful request to update a Smart Detector alert rule.

201 Created

AlertRule

Successful request to create a Smart Detector alert rule.

Other Status Codes

SmartDetectorErrorResponse

Error response describing why the operation failed.

Security

azure_auth

Azure Active Directory OAuth2 Flow

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

Scopes

Name Description
user_impersonation impersonate your user account

Examples

Create or update a Smart Detector alert rule

Sample Request

PUT https://management.azure.com/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyAlertRules/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule?api-version=2019-06-01

{
  "properties": {
    "description": "Sample smart detector alert rule description",
    "state": "Enabled",
    "severity": "Sev3",
    "frequency": "PT5M",
    "detector": {
      "id": "VMMemoryLeak"
    },
    "scope": [
      "/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyVms/providers/Microsoft.Compute/virtualMachines/vm1"
    ],
    "actionGroups": {
      "customEmailSubject": "My custom email subject",
      "customWebhookPayload": "{\"AlertRuleName\":\"#alertrulename\"}",
      "groupIds": [
        "/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/actionGroups/providers/microsoft.insights/actiongroups/MyActionGroup"
      ]
    },
    "throttling": {
      "duration": "PT20M"
    }
  }
}

Sample Response

{
  "id": "/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyAlertRules/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule",
  "type": "Microsoft.AlertsManagement/smartDetectorAlertRules",
  "name": "MyAlertRule",
  "location": "global",
  "tags": {},
  "properties": {
    "description": "Sample smart detector alert rule description",
    "state": "Enabled",
    "severity": "Sev3",
    "frequency": "PT5M",
    "detector": {
      "id": "VMMemoryLeak"
    },
    "scope": [
      "/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyVms/providers/Microsoft.Compute/virtualMachines/vm1"
    ],
    "actionGroups": [
      {
        "actionGroupId": "/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/actionGroups/providers/microsoft.insights/actiongroups/MyActionGroup"
      }
    ],
    "throttling": {
      "duration": "PT20M"
    }
  }
}
{
  "id": "/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyAlertRules/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule",
  "type": "Microsoft.AlertsManagement/smartDetectorAlertRules",
  "name": "MyAlertRule",
  "location": "global",
  "tags": {},
  "properties": {
    "description": "Sample smart detector alert rule description",
    "state": "Enabled",
    "severity": "Sev3",
    "frequency": "PT5M",
    "detector": {
      "id": "VMMemoryLeak"
    },
    "scope": [
      "/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyVms/providers/Microsoft.Compute/virtualMachines/vm1"
    ],
    "actionGroups": [
      {
        "actionGroupId": "/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/actionGroups/providers/microsoft.insights/actiongroups/MyActionGroup"
      }
    ],
    "throttling": {
      "duration": "PT20M"
    }
  }
}

Definitions

Name Description
ActionGroupsInformation

The Action Groups information, used by the alert rule.

AlertRule

The alert rule information

AlertRuleState

The alert rule state.

Detector

The detector information. By default this is not populated, unless it's specified in expandDetector

Severity

The alert rule severity.

SmartDetectorErrorResponse

Describe the format of an Error response.

ThrottlingInformation

Optional throttling information for the alert rule.

ActionGroupsInformation

The Action Groups information, used by the alert rule.

Name Type Description
customEmailSubject

string

An optional custom email subject to use in email notifications.

customWebhookPayload

string

An optional custom web-hook payload to use in web-hook notifications.

groupIds

string[]

The Action Group resource IDs.

AlertRule

The alert rule information

Name Type Default Value Description
id

string

The resource ID.

location

string

global

The resource location.

name

string

The resource name.

properties.actionGroups

ActionGroupsInformation

The alert rule actions.

properties.description

string

The alert rule description.

properties.detector

Detector

The alert rule's detector.

properties.frequency

string

The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes.

properties.scope

string[]

The alert rule resources scope.

properties.severity

Severity

The alert rule severity.

properties.state

AlertRuleState

The alert rule state.

properties.throttling

ThrottlingInformation

The alert rule throttling information.

tags

object

The resource tags.

type

string

The resource type.

AlertRuleState

The alert rule state.

Name Type Description
Disabled

string

Enabled

string

Detector

The detector information. By default this is not populated, unless it's specified in expandDetector

Name Type Description
description

string

The Smart Detector description. By default this is not populated, unless it's specified in expandDetector

id

string

The detector id.

imagePaths

string[]

The Smart Detector image path. By default this is not populated, unless it's specified in expandDetector

name

string

The Smart Detector name. By default this is not populated, unless it's specified in expandDetector

parameters

object

The detector's parameters.'

supportedResourceTypes

string[]

The Smart Detector supported resource types. By default this is not populated, unless it's specified in expandDetector

Severity

The alert rule severity.

Name Type Description
Sev0

string

Sev1

string

Sev2

string

Sev3

string

Sev4

string

SmartDetectorErrorResponse

Describe the format of an Error response.

Name Type Description
code

string

Error code

message

string

Error message indicating why the operation failed.

ThrottlingInformation

Optional throttling information for the alert rule.

Name Type Description
duration

string

The required duration (in ISO8601 format) to wait before notifying on the alert rule again. The time granularity must be in minutes and minimum value is 0 minutes