使用 Azure 活动日志和 Azure 服务运行状况监视应用生命周期事件

注意

Azure Spring Apps 是 Azure Spring Cloud 服务的新名称。 虽然该服务有新名称,但一些地方仍会使用旧名称,我们仍在更新屏幕截图、视频和图形等资产。

本文介绍如何使用 Azure 活动日志和 Azure 服务运行状况监视应用生命周期事件并设置警报。

Azure Spring Apps 提供用于监视应用程序状态和运行状况的内置工具。 应用生命周期事件可帮助你了解对应用程序所做的任何更改,以便可以根据需要执行操作。

先决条件

在 Azure 活动日志中监视由用户触发的应用生命周期事件

Azure 活动日志包含对订阅中的资源执行的操作所发出的资源事件。 应用程序生命周期事件(如启动、停止、重启)的以下详细信息已添加到 Azure 活动日志中:

  • 操作发生的时间。
  • 操作的状态。
  • 启动应用时创建了哪些实例。
  • 停止应用时删除了哪些实例。
  • 重启应用时删除和创建了哪些实例。

要在重启应用时查看受影响的实例,请在 Azure 门户中导航到 Azure Spring Apps 实例,然后在导航窗格中选择“活动日志”。

Screenshot of the Azure portal showing the Activity log page and the details pane open on the selected operation.

在 Azure 服务运行状况中监视应用生命周期事件

Azure 资源运行状况可帮助你诊断可能影响服务可用性的问题并获得相关支持。 这些问题包括服务事件、计划内维护期和区域中断。 应用程序重启事件会添加到 Azure 服务运行状况。 它们包括意外的事件(例如计划外的应用故障)和计划的操作(例如计划内维护)。

监视计划外的应用生命周期事件

在应用因计划外事件而重启时,Azure Spring Apps 实例会在 Azure 门户的“资源运行状况”部分中显示“已降级”状态。 “已降级”表示资源已检测到潜在的性能降低,但仍可供使用。 计划外事件的示例包括应用故障、运行状况检查失败和系统中断。

在 Azure 主页上,选择“服务运行状况”,然后选择“资源运行状况”。

在“运行状况历史记录”页中,可以查找最新状态、根本原因和受影响的实例。

Screenshot of the Azure portal showing the Resource Health page with the information and health history for degraded resource.

监视计划内的应用生命周期事件

在平台维护期间,应用可能会重启。 可以从 Azure 服务运行状况的“计划内维护”页面提前收到维护通知。

Screenshot of the Azure portal showing the Planned maintenance page for Service Health with a maintenance issue highlighted.

当平台维护发生时,Azure Spring Apps 实例将会显示“已降级”状态。 如果在平台维护期间需要重启,Azure Spring Apps 将执行滚动更新以增量更新应用程序。 滚动更新用于在不停机的情况下更新工作负载。 可以在运行状况历史记录页面中查找最新状态。

Screenshot of Azure portal example log for planned maintenance in progress.

注意

目前,Azure Spring Apps 每 2-4 个月执行一次定期计划内维护,以便升级基础 Kubernetes 版本。 有关详细的维护时间线,请查看“Azure 服务运行状况”页上的通知。

设置警报

可以为应用生命周期事件设置警报。 服务运行状况通知也存储在 Azure 活动日志中。 由于活动日志存储了大量信息,因此我们提供了单独的用户界面,以便更轻松地查看和设置有关服务运行状况通知的警报。

以下列表描述设置警报所需的关键步骤:

  1. 设置操作组,其中包含触发警报时要执行的操作。 示例操作类型包括发送语音呼叫、短信、电子邮件或触发各种类型的自动化操作。 各种警报可以使用相同的操作组或不同的操作组,具体取决于用户的要求。
  2. 设置预警规则。 警报使用操作组来通知用户某个特定应用生命周期事件的警报已被触发。

在活动日志上设置警报

使用以下步骤在 Azure 门户中创建活动日志预警规则:

  1. 导航到 Azure Spring Apps 实例,然后在导航窗格中选择“活动日志”。

  2. 选择任意日志以打开其详细信息窗格,然后选择“新建预警规则”。

    Screenshot of the Azure portal showing the Activity log page and the New Alert rule button highlighted for a selected log.

  3. 默认情况下,警报的范围限定为当前订阅。 选择“范围”选项卡,以选择其他订阅。

  4. 选择“条件”选项卡。选择“信号名称”,以配置条件的标准。

    Screenshot of Azure portal activity log alert condition.

  5. 选择“操作”选项卡。添加要应用于警报规则的操作组。

  6. 选择“查看 + 创建”,然后选择“创建”。

在 Azure 服务运行状况中设置用于监视应用生命周期事件的警报

使用以下步骤,在 Azure 门户中为服务运行状况通知创建预警规则。

  1. 在 Azure 主页上,在导航窗格中选择“服务运行状况”,然后选择“资源运行状况”。

  2. 选择“添加资源运行状况警报”。

    Screenshot of Azure portal Resource health page with the 'Add resource health alert' button highlighted.

  3. 选择“范围”选项卡。指定要应用于警报规则的资源。

    Screenshot of the Azure portal showing the Scope tab for Create an alert rule dialog when selected from the Resource health page.

  4. 选择“条件”选项卡。定义触发警报规则需满足的条件。

    Screenshot of the Azure portal showing the Condition tab for Create an alert rule dialog when selected from the Resource health page.

  5. 选择“操作”选项卡。添加要应用于警报规则的操作组。

  6. 选择“查看 + 创建”,然后选择“创建”。

设置用于监视计划内维护通知的警报

使用以下步骤,以在 Azure 门户中为计划内维护通知创建预警规则:

  1. 在 Azure 主页上,在导航窗格中选择“服务运行状况”,然后选择“运行状况警报”。

  2. 选择“添加服务运行状况警报”。

    Screenshot of Azure portal Health alerts page the 'Add service health alert' button highlighted.

  3. 为“范围”、“条件”和“操作”选项卡上的设置提供值。

    Screenshot of the Azure portal showing the Scope tab for Create an alert rule dialog when selected from the Health alerts page.

  4. 选择“查看 + 创建”,然后选择“创建”。