使用 Azure 资源管理器模板管理 Application Insights 智能检测规则Manage Application Insights smart detection rules using Azure Resource Manager templates

可以使用 Azure 资源管理器模板来管理和配置 Application Insights 中的智能检测规则。Smart detection rules in Application Insights can be managed and configured using Azure Resource Manager templates. 使用 Azure 资源管理器自动化部署新的 Application Insights 资源或修改现有资源的设置时,可以使用此方法。This method can be used when deploying new Application Insights resources with Azure Resource Manager automation, or for modifying the settings of existing resources.

智能检测规则配置Smart detection rule configuration

可以配置智能检测规则的以下设置:You can configure the following settings for a smart detection rule:

  • 是否已启用该规则(默认值为 true。)If the rule is enabled (the default is true.)
  • 找到检测项时,是否将电子邮件发送到订阅所有者、参与者或读取者(默认值为 true。)If emails should be sent to the subscription owners, contributors and readers when a detection is found (the default is true.)
  • 找到检测项时,应收到通知的其他任何电子邮件收件人。Any additional email recipients who should get a notification when a detection is found.
    • 电子邮件配置不适用于标记为“预览”的智能检测规则 。Email configuration is not available for Smart Detection rules marked as Preview.

为了让用户通过 Azure 资源管理器配置规则设置,智能检测规则配置现已在 Application Insights 资源中提供一个名为 ProactiveDetectionConfigs 的内部资源。To allow configuring the rule settings via Azure Resource Manager, the smart detection rule configuration is now available as an inner resource within the Application Insights resource, named ProactiveDetectionConfigs. 为了提供最大的灵活性,可为每个智能检测规则配置独特的通知设置。For maximal flexibility, each smart detection rule can be configured with unique notification settings.

示例Examples

以下几个示例演示如何使用 Azure 资源管理器模板配置智能检测规则的设置。Below are a few examples showing how to configure the settings of smart detection rules using Azure Resource Manager templates. 在所有示例中,Application Insights 资源名为 myApplication,“‘依赖项持续时间长’智能检测规则”的内部名称为 longdependencydurationAll samples refer to an Application Insights resource named “myApplication”, and to the "long dependency duration smart detection rule", which is internally named “longdependencyduration”. 请务必替换 Application Insights 资源名称,并指定相关的智能检测规则内部名称。Make sure to replace the Application Insights resource name, and to specify the relevant smart detection rule internal name. 在下表中查看每个智能检测规则的对应内部 Azure 资源管理器名称列表。Check the table below for a list of the corresponding internal Azure Resource Manager names for each smart detection rule.

禁用智能检测规则Disable a smart detection rule

{
      "apiVersion": "2018-05-01-preview",
      "name": "myApplication",
      "type": "Microsoft.Insights/components",
      "location": "[resourceGroup().location]",
      "properties": {
        "ApplicationId": "myApplication"
      },
      "resources": [
        {
          "apiVersion": "2018-05-01-preview",
          "name": "longdependencyduration",
          "type": "ProactiveDetectionConfigs",
          "location": "[resourceGroup().location]",
          "dependsOn": [
            "[resourceId('Microsoft.Insights/components', 'myApplication')]"
          ],
          "properties": {
            "name": "longdependencyduration",
            "sendEmailsToSubscriptionOwners": true,
            "customEmails": [],
            "enabled": false
          }
        }
      ]
    }

禁用发送有关某个智能检测规则的电子邮件通知Disable sending email notifications for a smart detection rule

{
      "apiVersion": "2018-05-01-preview",
      "name": "myApplication",
      "type": "Microsoft.Insights/components",
      "location": "[resourceGroup().location]",
      "properties": {
        "ApplicationId": "myApplication"
      },
      "resources": [
        {
          "apiVersion": "2018-05-01-preview",
          "name": "longdependencyduration",
          "type": "ProactiveDetectionConfigs",
          "location": "[resourceGroup().location]",
          "dependsOn": [
            "[resourceId('Microsoft.Insights/components', 'myApplication')]"
          ],
          "properties": {
            "name": "longdependencyduration",
            "sendEmailsToSubscriptionOwners": false,
            "customEmails": [],
            "enabled": true
          }
        }
      ]
    }

为智能检测规则添加更多的电子邮件收件人Add additional email recipients for a smart detection rule

{
      "apiVersion": "2018-05-01-preview",
      "name": "myApplication",
      "type": "Microsoft.Insights/components",
      "location": "[resourceGroup().location]",
      "properties": {
        "ApplicationId": "myApplication"
      },
      "resources": [
        {
          "apiVersion": "2018-05-01-preview",
          "name": "longdependencyduration",
          "type": "ProactiveDetectionConfigs",
          "location": "[resourceGroup().location]",
          "dependsOn": [
            "[resourceId('Microsoft.Insights/components', 'myApplication')]"
          ],
          "properties": {
            "name": "longdependencyduration",
            "sendEmailsToSubscriptionOwners": true,
            "customEmails": ['alice@contoso.com', 'bob@contoso.com'],
            "enabled": true
          }
        }
      ]
    }

智能检测规则名称Smart detection rule names

下表列出了门户中显示的智能检测规则名称,以及应在 Azure 资源管理器模板中为这些规则使用的内部名称。Below is a table of smart detection rule names as they appear in the portal, along with their internal names, that should be used in the Azure Resource Manager template.

Note

标记为“预览”的智能检测规则不支持电子邮件通知。Smart detection rules marked as preview don’t support email notifications. 因此,只能为这些规则设置已启用的属性。Therefore, you can only set the enabled property for these rules.

Azure 门户规则名称Azure portal rule name 内部名称Internal name
页面加载慢Slow page load time slowpageloadtimeslowpageloadtime
服务器响应慢Slow server response time slowserverresponsetimeslowserverresponsetime
依赖项持续时间长Long dependency duration longdependencydurationlongdependencyduration
服务器响应降级Degradation in server response time degradationinserverresponsetimedegradationinserverresponsetime
依赖项持续时间减少Degradation in dependency duration degradationindependencydurationdegradationindependencyduration
跟踪严重性比下降(预览)Degradation in trace severity ratio (preview) extension_traceseveritydetectorextension_traceseveritydetector
异常卷的异常增加(预览)Abnormal rise in exception volume (preview) extension_exceptionchangeextensionextension_exceptionchangeextension
检测到潜在的内存泄漏(预览)Potential memory leak detected (preview) extension_memoryleakextensionextension_memoryleakextension
检测到潜在的安全问题(预览)Potential security issue detected (preview) extension_securityextensionspackageextension_securityextensionspackage
检测到资源利用率问题(预览)Resource utilization issue detected (preview) extension_resourceutilizationextensionspackageextension_resourceutilizationextensionspackage

谁会收到(经典)警报通知?Who receives the (classic) alert notifications?

本节仅适用于智能检测经典警报,并将帮助优化警报通知以确保只有预期的接收人能收到通知。This section only applies to smart detection classic alerts and will help you optimize your alert notifications to ensure that only your desired recipients receive notifications. 若要详细了解经典警报与新的警报体验之间的区别,请参阅警报概述文章To understand more about the difference between classic alerts and the new alerts experience refer to the alerts overview article. 当前智能检测警报仅支持经典警报体验。Currently smart detection alerts only support the classic alerts experience. 有一个例外情况,是 Azure 云服务上的智能检测警报The one exception to this is smart detection alerts on Azure cloud services. 若要控制 Azure 云服务上智能检测警报的警报通知,可使用操作组To control alert notification for smart detection alerts on Azure cloud services use action groups.

  • 建议将智能检测/经典警报通知应用于特定收件人。We recommend the use of specific recipients for smart detection/classic alert notifications.

  • 对于智能检测警报,“批/组”复选框选项(如果已启用)将发送给订阅中具有所有者、参与者或读者角色的用户 。For smart detection alerts, the bulk/group check-box option, if enabled, sends to users with owner, contributor, or reader roles in the subscription. 实际上,可以访问订阅 Application Insights 资源的_所有_用户均会接收到通知。In effect, all users with access to the subscription the Application Insights resource are in scope and will receive notifications.

Note

如果当前使用“批/组”复选框选项并禁用它,则无法还原更改 。If you currently use the bulk/group check-box option, and disable it, you will not be able to revert the change.

后续步骤Next Steps

了解有关自动检测的详细信息:Learn more about automatically detecting: