您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

常见警报架构Common alert schema

本文介绍通用警报架构是什么、使用它的好处以及启用它的方法。This article describes what the common alert schema is, the benefits of using it and how to enable it.

通用警报架构是什么?What is the common alert schema?

通用警报架构将目前 Azure 中的警报通知的使用体验进行了标准化。The common alert schema standardizes the consumption experience for alert notifications in Azure today. 从历史上看,目前 Azure 中的三种警报类型(指标、日志、活动日志)一直有其自己的电子邮件模板、Webhook 架构等。现在,使用通用警报架构时可以收到架构一致的警报通知。Historically, the three alert types in Azure today (metric, log, and activity log) have had their own email templates, webhook schemas, etc. With the common alert schema, you can now receive alert notifications with a consistent schema.

任何警报实例都会描述 受影响的资源警报原因 。这些实例在以下部分的通用架构中进行介绍:Any alert instance describes the resource that was affected and the cause of the alert , and these instances are described in the common schema in the following sections:

  • 概要 :一组通用于所有警报类型的 标准化字段 ,描述对 什么资源 发出警报,此外还有其他通用警报元数据(例如,严重性或说明)。Essentials : A set of standardized fields , common across all alert types, which describe what resource the alert is on along with additional common alert metadata (for example, severity or description).
  • 警报上下文 :一组用于描述 警报原因 的字段,此外还有 因警报类型 而异的字段。Alert Context : A set of fields which describe the cause of the alert , with fields that vary based on the alert type. 例如,指标警报在警报上下文中会有指标名称和指标值之类的字段,而活动日志警报会包含生成警报的事件的相关信息。For example, a metric alert would have fields like the metric name and metric value in the alert context, whereas an activity log alert would have information about the event that generated the alert.

我们从客户处听到的典型集成方案涉及将警报实例基于某个中心(例如资源组)路由到相关团队,然后该负责团队就开始处理它。The typical integration scenarios we hear from customers involve the routing of the alert instance to the concerned team based on some pivot (for example, resource group), after which the responsible team starts working on it. 有了通用警报架构以后,可以使用重要字段,将上下文字段保留原样,方便相关团队进一步进行调查,这样就可以跨警报类型实现路由逻辑的标准化。With the common alert schema, you can have standardized routing logic across alert types by leveraging the essential fields, leaving the context fields as is for the concerned teams to investigate further.

这意味着可以减少集成数,大大简化其管理和维护过程。 This means that you can potentially have fewer integrations, making the process of managing and maintaining them a much simpler task. 另外,未来的警报有效负载扩充(例如,自定义、诊断扩充等)只会出现在通用架构中。Additionally, future alert payload enrichments (for example, customization, diagnostic enrichment, etc.) will only surface up in the common schema.

通用警报架构带来哪些增强功能?What enhancements does the common alert schema bring?

通用警报架构将主要呈现在警报通知中。The common alert schema will primarily manifest itself in your alert notifications. 你将要看到的增强功能已列在下面:The enhancements that you will see are listed below:

操作Action 增强功能Enhancements
SMSSMS 一个适用于所有警报类型的一致的 SMS 模板。A consistent SMS template for all alert types.
EmailEmail 一个一致且详细的电子邮件模板,可以轻松快捷地诊断问题。A consistent and detailed email template, allowing you to easily diagnose issues at a glance. 嵌入式深度链接指向门户中的警报实例和受影响的资源,确保你可以快速跳转到修正过程。Embedded deep-links to the alert instance on the portal and the affected resource ensure that you can quickly jump into the remediation process.
Webhook/逻辑应用/Azure Functions/自动化 RunbookWebhook/Logic App/Azure Function/Automation Runbook 一个适用于所有警报类型的一致的 JSON 结构,用于轻松地跨不同警报类型构建集成。A consistent JSON structure for all alert types, which allows you to easily build integrations across the different alert types.

有了这个新的架构,在不久的将来还可以跨 Azure 门户和 Azure 移动应用实现更丰富的警报使用体验。The new schema will also enable a richer alert consumption experience across both the Azure portal and the Azure mobile app in the immediate future.

详细了解 Webhook/逻辑应用/Azure Functions/自动化 Runbook 的架构定义。Learn more about the schema definitions for Webhooks/Logic Apps/Azure Functions/Automation Runbooks.

备注

以下操作不支持通用警报架构:ITSM 连接器。The following actions do not support the common alert schema: ITSM Connector.

如何启用通用警报架构?How do I enable the common alert schema?

可以使用操作组通过门户和 REST API 选择加入通用警报架构,或者选择退出它。You can opt in or opt out to the common alert schema through Action Groups, on both the portal and through the REST API. 可以在操作级别通过切换转到新的架构。The toggle to switch to the new schema exists at an action level. 例如,对于电子邮件操作和 Webhook 操作,必须单独选择加入。For example, you have to separately opt in for an email action and a webhook action.

备注

  1. 以下警报类型默认支持通用架构(不需选择加入):The following alert types support the common schema by default (no opt in required):
    • 智能检测警报Smart detection alerts
  2. 以下警报类型目前不支持通用架构:The following alert types currently do not support the common schema:

通过 Azure 门户Through the Azure portal

选择加入通用警报架构

  1. 在操作组中打开现有的或新的操作。Open any existing or a new action in an action group.
  2. 选择“是”,通过切换启用通用警报架构,如图所示。Select ‘Yes’ for the toggle to enable the common alert schema as shown.

通过操作组 REST APIThrough the Action Groups REST API

也可使用操作组 API 来选择加入通用警报架构。You can also use the Action Groups API to opt in to the common alert schema. 进行创建或更新 REST API 调用时,可以针对下述任意操作将标记 "useCommonAlertSchema" 设置为 true(选择加入)或 false(选择退出):电子邮件/Webhook/逻辑应用/Azure Functions/自动化 Runbook。While making the create or update REST API call, you can set the flag "useCommonAlertSchema" to 'true' (to opt in) or 'false' (to opt out) for any of the following actions - email/webhook/logic app/Azure Function/automation runbook.

例如,针对创建或更新 REST API 设置的以下请求正文会执行以下操作:For example, the following request body made to the create or update REST API will do the following:

  • 针对电子邮件操作“John Doe 的电子邮件”启用通用警报架构Enable the common alert schema for the email action "John Doe's email"
  • 针对电子邮件操作“Jane Smith 的电子邮件”禁用通用警报架构Disable the common alert schema for the email action "Jane Smith's email"
  • 针对 Webhook 操作“示例 Webhook”启用通用警报架构Enable the common alert schema for the webhook action "Sample webhook"
{
  "properties": {
    "groupShortName": "sample",
    "enabled": true,
    "emailReceivers": [
      {
        "name": "John Doe's email",
        "emailAddress": "johndoe@email.com",
        "useCommonAlertSchema": true
      },
      {
        "name": "Jane Smith's email",
        "emailAddress": "janesmith@email.com",
        "useCommonAlertSchema": false
      }
    ],
    "smsReceivers": [
      {
        "name": "John Doe's mobile",
        "countryCode": "1",
        "phoneNumber": "1234567890"
      },
      {
        "name": "Jane Smith's mobile",
        "countryCode": "1",
        "phoneNumber": "0987654321"
      }
    ],
    "webhookReceivers": [
      {
        "name": "Sample webhook",
        "serviceUri": "http://www.example.com/webhook",
        "useCommonAlertSchema": true
      }
    ]
  },
  "location": "Global",
  "tags": {}
}

后续步骤Next steps