警报任务Alert tasks

重要

此功能目前以公共预览版提供。This feature is in Public Preview. 请联系 Azure Databricks 代表,以申请访问权限。Contact your Azure Databricks representative to request access.

创建警报Create an alert

  1. 单击Click the 边栏中的 “模型”图标。icon in the sidebar.

  2. 单击“+新建警报”。Click + New Alert.

  3. 搜索目标查询。Search for a target query. 如果没看到所需的查询,请确保它已发布且未使用参数。If you don’t see it the one you want, make sure it is published and does not use parameters.

    目标查询Target query

  4. 在“触发时间”字段中配置警报。In the Trigger when field, configure the alert.

    • “值列”下拉列表控制计算查询结果的哪个字段。The Value column drop-down controls which field of your query result is evaluated.
    • “条件”下拉列表控制要应用的逻辑操作。The Condition drop-down controls the logical operation to be applied.
    • 使用指定的条件将“阈值”文本输入与值列进行比较。The Threshold text input is compared against the Value column using the Condition you specify.

    警报设置Alert settings

    备注

    如果目标查询返回多个记录,则 SQL Analytics 警报对第一个记录起作用。If a target query returns multiple records, SQL Analytics alerts act on the first one. 更改值列设置时,其下方会显示顶行中该字段的当前值。As you change the Value column setting, the current value of that field in the top row is shown beneath it.

  5. 在“触发时发送通知”字段中,选择触发警报时发送的通知数量:In the When triggered, send notification field, select how many notifications are sent when your alert is triggered:

    • 仅一次:当警报状态OK 更改为 TRIGGERED 时发送通知。Just once: Send a notification when the alert status changes from OK to TRIGGERED.
    • 每次评估警报时:每当警报状态为 TRIGGERED 时,无论在上次评估中其状态如何,都发送通知。Each time alert is evaluated: Send a notification whenever the alert status is TRIGGERED regardless of its status at the previous evaluation.
    • 最多每次:每当警报状态在特定时间间隔内为 TRIGGERED 时发送通知。At most every: Send a notification whenever the alert status is TRIGGERED at a specific interval. 此选项可让你避免经常触发的警报遇到通知垃圾邮件。This choice lets you avoid notification spam for alerts that trigger often.

    无论选择哪种通知设置,只要状态从 OK 更改为 TRIGGERED 或从 TRIGGERED 更改为 OK,你都会收到通知。Regardless of which notification setting you choose, you receive a notification whenever the status goes from OK to TRIGGERED or from TRIGGERED to OK. 如果状态在相邻两次执行中都是 TRIGGERED,则计划设置将影响你收到的通知数量。The schedule settings affect how many notifications you will receive if the status remains TRIGGERED from one execution to the next. 有关详细信息,请查看通知频率For details, see Notification frequency.

  6. 在“模板”下拉列表中,选择一个模板:In the Template drop-down, choose a template:

    • 使用默认模板:警报通知是一条消息,其中有指向警报配置屏幕和查询屏幕的链接。Use default template: Alert notification is a message with links to the Alert configuration screen and the Query screen.
    • 使用自定义模板:警报通知包括有关警报的更多特定信息。Use custom template: Alert notification includes more specific information about the alert.
      1. 会显示一个框,其中有输入主题和正文的字段。A box displays, consisting of input fields for subject and body. 任何静态内容都有效,你可合并内置模板变量:Any static content is valid, and you can incorporate built-in template variables:

        • ALERT_STATUS:已评估的警报状态(字符串)。ALERT_STATUS: The evaluated alert status (string).
        • ALERT_CONDITION:警报条件运算符(字符串)。ALERT_CONDITION: The alert condition operator (string).
        • ALERT_THRESHOLD:警报阈值(字符串或数字)。ALERT_THRESHOLD: The alert threshold (string or number).
        • ALERT_NAME:警报名称(字符串)。ALERT_NAME: The alert name (string).
        • ALERT_URL:警报页 URL(字符串)。ALERT_URL: The alert page URL (string).
        • QUERY_NAME:关联的查询名称(字符串)。QUERY_NAME: The associated query name (string).
        • QUERY_URL:关联的查询页 URL(字符串)。QUERY_URL: The associated query page URL (string).
        • QUERY_RESULT_VALUE:查询结果值(字符串或数字)。QUERY_RESULT_VALUE: The query result value (string or number).
        • QUERY_RESULT_ROWS:查询结果行(值数组)。QUERY_RESULT_ROWS: The query result rows (value array).
        • QUERY_RESULT_COLS:查询结果列(字符串数组)。QUERY_RESULT_COLS: The query result columns (string array).

        例如,示例主题可以是:Alert "{{ALERT_NAME}}" changed status to {{ALERT_STATUS}}An example subject, for instance, could be: Alert "{{ALERT_NAME}}" changed status to {{ALERT_STATUS}}.

      2. 单击“预览”切换按钮来预览呈现的结果。Click the Preview toggle button to preview the rendered result.

        重要

        若要验证模板变量是否正确呈现,预览功能很有用。The preview is useful for verifying that template variables are rendered correctly. 它不是最终通知内容的准确表示形式,因为每个警报目标会以不同方式显示通知。It is not an accurate representation of the eventual notification content, as each alert destination can display notifications differently.

      3. 单击“保存更改”按钮。Click the Save Changes button.

  7. 单击“创建警报”。Click Create Alert.

  8. 选择警报目标Choose an alert destination.

    重要

    如果跳过此步骤,那么在触发警报时,你将不会收到通知。If you skip this step you will not be notified when the alert is triggered.

    警报目标Alert destination

通知频率Notification frequency

每当 SQL Analytics 检测到警报状态已从 OK 更改为 TRIGGERED 时(反之亦然),就会将通知发送到你选择的警报目标。SQL Analytics sends notifications to your chosen alert destinations whenever it detects that the Alert status has changed from OK to TRIGGERED or vice versa. 请思考以下示例,其中对计划每天运行一次的查询配置了警报。Consider this example where an Alert is configured on a query that is scheduled to run once daily. 下表显示了警报的每日状态。The daily status of the Alert appears in the following table. 星期一之前,警报状态为 OKPrior to Monday the alert status was OK.

日期Day 警报状态Alert Status
星期一Monday 确定OK
星期二Tuesday 确定OK
星期三Wednesday 已触发TRIGGERED
星期四Thursday 已触发TRIGGERED
星期五Friday 已触发TRIGGERED
星期六Saturday 已触发TRIGGERED
星期日Sunday 确定OK

如果通知频率设置为 Just Once,则当状态从 OK 更改为 TRIGGERED 时,SQL Analytics 会在周三发送通知,反之则在周日发送通知。If the notification frequency is set to Just Once, SQL Analytics sends a notification on Wednesday when the status changed from OK to TRIGGERED and again on Sunday when it switches back. 它不会在周四、周五或周六发送警报,除非你专门将其配置为在这几天发送,因为警报状态在这几天执行期间没有发生变化。It does not send alerts on Thursday, Friday, or Saturday unless you specifically configure it to do so because the Alert status did not change between executions on those days.

配置警报权限Configure alert permissions

若要配置可管理和运行警报的人员,请查看警报访问控制To configure who can manage and run alerts, see Alert access control.