使用 Azure 门户为 Azure SQL 托管实例创建警报Create alerts for Azure SQL Managed Instance using the Azure portal

适用于: Azure SQL 托管实例

本文说明如何使用 Azure 门户为 Azure SQL 托管实例数据库中的数据库设置警报。This article shows you how to set up alerts for databases in Azure SQL Managed Instance Database using the Azure portal. 警报可以向你发送电子邮件、调用 web hook、执行 Azure Function、runbook、在某些指标(例如实例存储大小或 CPU 使用率)达到预定义的阈值时发送文本消息。Alerts can send you an email, call a web hook, execute Azure Function, runbook, send a text message when some metric, such is for example instance storage size, or CPU usage, reaches a predefined threshold. 本文还提供了设置警报期限的最佳做法。This article also provides best practices for setting alert periods.

概述Overview

可以根据监控指标或事件接收 Azure 服务的警报。You can receive an alert based on monitoring metrics for, or events on, your Azure services.

  • 指标值 - 当指定指标的值在任一方向越过了指定的阈值时警报将触发。Metric values - The alert triggers when the value of a specified metric crosses a threshold you assign in either direction. 也就是说,当条件先是满足以及之后不再满足该条件时,警报都会触发。That is, it triggers both when the condition is first met and then afterwards when that condition is no longer being met.

可以配置警报以在其触发时执行以下操作:You can configure an alert to do the following when it triggers:

  • 向服务管理员和共同管理员发送电子邮件通知Send email notifications to the service administrator and coadministrators
  • 将电子邮件发送到指定的其他电子邮件地址。Send email to additional emails that you specify.
  • 向组发送电话号码Send text message to a phone number
  • 调用 WebhookCall a webhook
  • 调用 Azure FunctionCall Azure Function
  • 调用 Azure runbookCall Azure runbook

可以使用 Azure 门户、PowerShell 或 Azure CLI 或者 Azure Monitor REST API 来配置和获取警报规则的相关信息。You can configure and get information about alert rules using the Azure portal, PowerShell or the Azure CLI or Azure Monitor REST API.

适用于托管实例的警报指标Alerting metrics available for managed instance

重要

警报指标仅适用于托管实例。Alerting metrics are available for managed instance only. 警报指标不适用于托管实例中的单个数据库。Alerting metrics for individual databases in managed instance are not available. 另一方面,数据库诊断遥测可按诊断日志的形式提供。Database diagnostics telemetry is on the other hand available in the form of diagnostics logs.

以下托管实例指标可用于警报配置:The following managed instance metrics are available for alerting configuration:

指标Metric 说明Description 度量单位 \ 可能值Unit of measure \ possible values
CPU 平均百分比Average CPU percentage 选定时间段内 CPU 使用率的平均百分比。Average percentage of CPU utilization in selected time period. 0-100(百分比)0-100 (percent)
已读取的 IO 字节数IO bytes read 选定时间段内已读取的 IO 字节数。IO bytes read in the selected time period. 字节Bytes
已写入的 IO 字节数IO bytes written 选定时间段内已写入的 IO 字节。IO bytes written in the selected time period. 字节Bytes
IO 请求计数IO requests count 选定时间段内的 IO 请求计数。Count of IO requests in the selected time period. 数值Numerical
预留的存储空间Storage space reserved 当前为托管实例预留的最大存储空间。Current max. storage space reserved for the managed instance. 随资源缩放操作所发生的变化。Changes with resource scaling operation. MB(兆字节)MB (Megabytes)
已使用的存储空间Storage space used 选定时间段内已使用的存储空间。Storage space used in the selected period. 随数据库和实例的存储消耗所发生的变化。Changes with storage consumption by databases and the instance. MB(兆字节)MB (Megabytes)
虚拟核心计数Virtual core count 为托管实例预配的 vCore 数量。vCores provisioned for the managed instance. 随资源缩放操作所发生的变化。Changes with resource scaling operation. 4-80 (vCore)4-80 (vCores)

使用 Azure 门户创建指标的警报规则Create an alert rule on a metric with the Azure portal

  1. 在 Azure 门户中,查找想要监视的托管实例,并选择该实例。In Azure portal, locate the managed instance you are interested in monitoring, and select it.

  2. 在监视部分中选择“指标”菜单项。Select Metrics menu item in the Monitoring section.

    监视

  3. 在下拉菜单上,选择要设置警报的指标之一(示例中显示了已使用的存储空间)。On the drop-down menu, select one of the metrics you wish to set up your alert on (Storage space used is shown in the example).

  4. 选择聚合时间段 - 在给定时间段内达到的平均值、最小值或最大值(Avg、Min 或 Max)。Select aggregation period - average, minimum, or maximum reached in the given time period (Avg, Min, or Max).

  5. 选择“新建警报规则”Select New alert rule

  6. 在“创建警报规则”窗格中,单击“条件名称”(示例中显示了已使用的存储空间)In the Create alert rule pane click on Condition name (Storage space used is shown in the example)

    定义条件

  7. 在“配置信号逻辑”窗格中,定义运算符、聚合类型和阈值On the Configure signal logic pane, define Operator, Aggregation type, and Threshold value

    • 运算符类型选项有“大于”、“等于”和“小于”(阈值)Operator type options are greater than, equal and less than (the threshold value)
    • 聚合类型选项有“最小值”、“最大值”或“平均值”(在聚合粒度期间内)Aggregation type options are min, max or average (in the aggregation granularity period)
    • 阈值是根据运算符和聚合条件计算的警报值Threshold value is the alert value which will be evaluated based on the operator and aggregation criteria

    Configure_signal_logic

    在屏幕截图所示的示例中,值 1840876 MB 表示阈值为 1.8 TB。In the example shown in the screenshot, value of 1840876 MB is used representing a threshold value of 1.8 TB. 由于示例中的操作符设置为“大于”,所以如果托管实例上的存储空间消耗量超过 1.8 TB,就会创建警报。As the operator in the example is set to greater than, the alert will be created if the storage space consumption on the managed instance goes over 1.8 TB. 请注意,存储空间指标的阈值必须以 MB 表示。Note that the threshold value for storage space metrics must be expressed in MB.

  8. 设置评估期 - 聚合粒度(以分钟为单位)和评估频率。Set the evaluation period - aggregation granularity in minutes and frequency of evaluation. 评估频率指示警报系统定期检查阈值条件是否满足的检查时间。The frequency of evaluation will denote time the alerting system will periodically check if the threshold condition has been met.

  9. 选择操作组。Select action group. 随即显示“操作组”窗格,通过该窗格可以选择现有操作或创建新操作。Action group pane will show up through which you will be able to select an existing, or create a new action. 此操作定义在触发警报时发生的操作(例如,发送电子邮件、执行 webhook、Azure function 或 runbook)。This action defines that will happen upon triggering an alert (for example, sending email, executing a webhook, Azure function, or a runbook, for example).

    Select_action_group

    • 若要创建新的操作组,请选择“+ 创建操作组”To create new action group, select +Create action group

      Create_action_group_alerts

    • 定义警报方式:输入操作组名称、短名称、操作名称并选择操作类型。Define how do you want to be alerted: Enter action group name, short name, action name and select Action Type. 操作类型定义是否通过电子邮件、文本消息通知你,或者是否将执行 webhook、Azure function、runbook。The Action Type defines if you will be notified via email, text message, or if perhaps webhook, Azure function, runbook will be executed.

      Define_how_to_be_alerted

  10. 填写用于记录的警报规则详细信息,选择严重性类型。Fill in the alert rule details for your records, select the severity type.

    Rule_description

  • 单击“创建警报规则”按钮,完成警报规则的创建。Complete creating the alert rule by clicking on Create alert rule button.

新的警报规则将在几分钟内激活,并根据设置触发。New alert rule will become active within a few minutes and will be triggered based on your settings.

验证警报Verifying alerts

备注

若要抑制干扰警报,请参阅使用操作规则抑制警报To supress noisy alerts, see Supression of alerts using action rules.

设置警报规则后,请验证警报触发情况及其频率是否符合需求。Upon setting up an alerting rule, verify that you are satisfied with the alerting trigger and its frequency. 对于此页上显示的关于针对已使用的存储空间设置警报的示例,如果警报选项是电子邮件,则可能会收到电子邮件,如下所示。For the example shown on this page for setting up an alert on storage space used, if your alerting option was email, you might receive email such is the one shown below.

alert_example

电子邮件显示警报名称、阈值的详细信息以及触发警报的原因,可帮助你验证警报并对警报进行故障排除。The email shows the alert name, details of the threshold and why the alert was triggered helping you to verify and troubleshoot your alert. 可以使用“在 Azure 门户中查看”按钮查看通过 Azure 门户中的电子邮件接收的警报。You can use See in Azure portal button to view alert received via email in Azure portal.

查看、暂停、激活、修改和删除现有警报规则View, suspend, activate, modify and delete existing alert rules

备注

需要通过 Azure 门户面板的“警报”菜单管理现有警报。Existing alerts need to be managed from Alerts menu from Azure portal dashboard. 无法从托管实例资源边栏选项卡修改现有警报。Existing alerts cannot be modified from Managed Instance resource blade.

若要查看、暂停、激活、修改和删除现有警报:To view, suspend, activate, modify and delete existing alerts:

  1. 使用 Azure 门户搜索搜索警报。Search for Alerts using Azure portal search. 单击“警报”。Click on Alerts.

    find_alerts

    或者,也可以单击 Azure 导航栏上的警报(如果已配置)。Alternatively, you could also click on Alerts on the Azure navigation bar, if you have it configured.

  2. 在“警报”窗格中,选择“管理警报规则”。On the Alerts pane, select Manage alert rules.

    modify_alerts

    随即显示现有警报的列表。List of existing alerts will show up. 选择单个现有警报规则进行管理。Select an individual existing alert rule to manage it. 可以根据你的偏好修改和调整现有的活动规则。Existing active rules can be modified and tuned to your preference. 也可以不删除活动规则而是将其挂起。Active rules can also be suspended without being deleted.

后续步骤Next steps