管理 Azure Monitor 工作区

本文介绍如何创建和删除 Azure Monitor 工作区。 配置适用于 Prometheus 的 Azure Monitor 托管服务时,可以选择现有的 Azure Monitor 工作区或创建新的工作区。

注释

创建 Azure Monitor 工作区时,<azure-monitor-workspace-name> 形式的资源组中默认自动创建 MA_<azure-monitor-workspace-name>_<location>_managed 形式的数据收集规则和数据收集终结点。 如果有任何对资源或资源组名称有限制的 Azure 策略,请创建豁免,使这些资源不参与评估。

先决条件

  • 一份 Azure 订阅。 如果没有 Azure 订阅,可在开始前创建一个试用帐户
  • 用于保存Azure Monitor工作区的资源组。
  • 资源组上的 参与者 角色。 需要此角色才能创建或删除Azure Monitor工作区。

创建 Azure Monitor 工作区

  1. 在 Azure 门户中打开“Azure Monitor 工作区”菜单。

  2. 选择 创建

    Azure Monitor 工作区菜单和页面的屏幕截图。

  3. “创建Azure Monitor工作区”上,选择要在其中创建工作区的订阅资源组

  4. 提供工作区的名称和区域。

  5. 选择“查看 + 创建”以创建工作区。

创建 Azure Monitor 工作区时,会创建新的资源组。 资源组名称采用以下格式:MA_<azure-monitor-workspace-name>_<location>_managed,其中已标记化元素采用小写。 资源组包含一个数据收集终结点,以及一套与工作区同名的数据收集规则。 删除工作区时,会自动删除资源组及其资源。

若要将适用于 Prometheus 的 Azure Monitor 托管服务连接到 Azure Monitor 工作区,请参阅从 AKS 群集收集 Prometheus 指标

小窍门

为Azure Monitor工作区启用建议的警报,以监视引入限制和配额。 若要启用建议的警报,请参阅为Azure Monitor工作区启用建议的警报

配置资源上下文访问模式

Log Analytics工作区类似,Azure Monitor工作区提供资源上下文访问模式,以便为查询工作区中的数据的用户启用更精细的 Azure RBAC 资源权限。 此访问模式具有以下优势:

  • 用户不需要知道要查询哪些工作区来查询其查询范围限定为的指标
  • 用户不需要直接访问存储其资源的指标的工作区

有关详细信息,请参阅管理对Azure Monitor工作区的访问权限

删除 Azure Monitor 工作区

删除 Azure Monitor 工作区时,与 Log Analytics 工作区不同的是,不会执行软删除操作。 工作区中的数据会立即删除,并且没有恢复选项。

  1. 在 Azure 门户中打开“Azure Monitor 工作区”菜单。

  2. 选择工作区。

  3. 选择 删除

    Azure Monitor 工作区“删除”按钮的屏幕截图。

确认删除

删除Azure Monitor工作区时,Azure还会删除窗体MA_<azure-monitor-workspace-name>_<location>_managed中的托管资源组。 若要确认删除,请验证此资源组是否不再存在:

az group show --name MA_<azure-monitor-workspace-name>_<location>_managed

该命令返回一个错误,指出找不到资源组,这确认已删除托管资源。

将 Azure Monitor 工作区连接到 Azure 托管 Grafana 工作区,以允许 Grafana 在 Grafana 仪表板中使用 Azure Monitor 工作区数据。 可以将Azure Monitor工作区连接到多个 Grafana 工作区,并将 Grafana 工作区连接到多个Azure Monitor工作区。 Azure 托管 Grafana 和 Azure Monitor 工作区可能位于不同区域。

若要将自我管理的 Grafana 实例链接到 Azure Monitor 工作区,请参阅将 Grafana 连接到 Azure Monitor Prometheus 指标

注释

将 Azure Monitor 工作区作为数据源添加到 Grafana 时,它将以 Prometheus_<azure monitor workspace query endpoint> 的形式列出。

  1. 在 Azure 门户中打开“Azure Monitor 工作区”菜单。
  2. 选择工作区。
  3. 选择“链接的 Grafana 工作区”。
  4. 选择 Grafana 工作区。

后续步骤