你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

适用于 Linux 的 Azure Monitor 依赖项虚拟机扩展

用于 VM 的 Azure Monitor 映射功能从 Microsoft Dependency Agent 获取其数据。 适用于 Linux 的 Azure VM 依赖关系代理虚拟机扩展在 Azure 虚拟机上安装依赖关系代理。 本文档详细介绍适用于 Linux 的 Azure VM 依赖项代理虚拟机扩展支持的平台、配置和部署选项。

先决条件

操作系统

由于 Azure VM Dependency Agent 在内核级别运行,因此操作系统支持也依赖于内核版本。 从 Dependency Agent 版本 9.10.* 开始,代理支持 * 内核。 下表列出了 Dependency Agent 的主要和次要 Linux OS 版本以及支持的内核版本。

注意

使用 Dependency Agent 9.10.15 及更高版本时,允许不受支持的内核版本的安装,但代理将在降级模式下运行。 在此模式下,不会收集存储在 VMConnection 和 VMBoundport 表中的连接和端口数据。 VMProcess 表可能包含一些数据,但数据量最少。

分发 OS 版本 内核版本
Red Hat Linux 8 8.6 4.18.0-372.*el8.x86_64、4.18.0-372.*el8_6.x86_64
8.5 4.18.0-348.*el8_5.x86_644.18.0-348.*el8.x86_64
8.4 4.18.0-305.*el8.x86_64, 4.18.0-305.*el8_4.x86_64
8.3 4.18.0-240.*el8_3.x86_64
8.2 4.18.0-193.*el8_2.x86_64
8.1 4.18.0-147.*el8_1.x86_64
8.0 4.18.0-80.*el8.x86_64
4.18.0-80.*el8_0.x86_64
Red Hat Linux 7 7.9 3.10.0-1160
7.8 3.10.0-1136
7.7 3.10.0-1062
7.6 3.10.0-957
7.5 3.10.0-862
7.4 3.10.0-693
Red Hat Linux 6 6.10 2.6.32-754
6.9 2.6.32-696
CentOS Linux 8 8.6 4.18.0-372.*el8.x86_64、4.18.0-372.*el8_6.x86_64
8.5 4.18.0-348.*el8_5.x86_644.18.0-348.*el8.x86_64
8.4 4.18.0-305.*el8.x86_64, 4.18.0-305.*el8_4.x86_64
8.3 4.18.0-240.*el8_3.x86_64
8.2 4.18.0-193.*el8_2.x86_64
8.1 4.18.0-147.*el8_1.x86_64
8.0 4.18.0-80.*el8.x86_64
4.18.0-80.*el8_0.x86_64
CentOS Linux 7 7.9 3.10.0-1160
7.8 3.10.0-1136
7.7 3.10.0-1062
CentOS Linux 6 6.10 2.6.32-754.3.5
2.6.32-696.30.1
6.9 2.6.32-696.30.1
2.6.32-696.18.7
Ubuntu Server 20.04 5.8
5.4*
18.04 5.3.0-1020
5.0(包括 Azure 优化内核)
4.18*
4.15*
16.04.3 4.15.*
16.04 4.13.*
4.11.*
4.10.*
4.8.*
4.4.*
14.04 3.13.*-generic
4.4.*-generic
SUSE Linux 12 Enterprise Server 12 SP5 4.12.14-122.*-default, 4.12.14-16.*-azure
12 SP4 4.12.*(包括 Azure 优化内核)
12 SP3 4.4.*
12 SP2 4.4.*
SUSE Linux 15 Enterprise Server 15 SP1 4.12.14-197.*-default, 4.12.14-8.*-azure
15 4.12.14-150.*-default
Debian 9 4.9

注意

具有基于 Ampere Altra ARM 的处理器的 Azure 虚拟机不支持 Dependency Agent。

扩展架构

以下 JSON 显示了 Azure Linux VM 上 Azure VM 依赖项代理扩展的架构。

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "vmName": {
        "type": "string",
        "metadata": {
            "description": "The name of existing Linux Azure VM."
      }
    }
  },
  "variables": {
      "vmExtensionsApiVersion": "2017-03-30"
  },
  "resources": [
    {
      "type": "Microsoft.Compute/virtualMachines/extensions",
      "name": "[concat(parameters('vmName'),'/DAExtension')]",
      "apiVersion": "[variables('vmExtensionsApiVersion')]",
      "location": "[resourceGroup().location]",
      "dependsOn": [],
      "properties": {
          "publisher": "Microsoft.Azure.Monitoring.DependencyAgent",
          "type": "DependencyAgentLinux",
          "typeHandlerVersion": "9.5",
          "autoUpgradeMinorVersion": true,
          "settings": {
              "enableAMA": "true"
        }
      }
    }
  ],
    "outputs": {
    }
}

属性值

名称 值/示例
apiVersion 2015-01-01
发布者 Microsoft.Azure.Monitoring.DependencyAgent
type DependencyAgentLinux
typeHandlerVersion 9.5
设置 “enableAMA”:“true”

重要

如果你使用的是 Azure Monitor 代理,请务必将 enableAMA 添加到模板;否则,依赖关系代理会尝试将数据发送到旧版 Log Analytics 代理。

模板部署

可使用 Azure 资源管理器模板部署 Azure VM 扩展。 可以在 Azure 资源管理器模板中使用上一部分中详细介绍的 JSON 架构,以便在 Azure 资源管理器模板部署过程中运行 Azure VM 依赖项代理扩展。

用于虚拟机扩展的 JSON 可以嵌套在虚拟机资源中。 或者,可以将其置于资源管理器 JSON 模板的根部或顶层。 JSON 的位置会影响资源名称和类型的值。 有关详细信息,请参阅设置子资源的名称和类型

以下示例假定依赖项代理扩展嵌套在虚拟机资源内。 嵌套扩展资源时,JSON 放置在虚拟机的 "resources": [] 对象中。

{
	"type": "extensions",
	"name": "DAExtension",
	"apiVersion": "[variables('apiVersion')]",
	"location": "[resourceGroup().location]",
	"dependsOn": [
      "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
	],
	"properties": {
        "publisher": "Microsoft.Azure.Monitoring.DependencyAgent",
        "type": "DependencyAgentLinux",
        "typeHandlerVersion": "9.5",
        "autoUpgradeMinorVersion": true,
        "settings": {
            "enableAMA": "true"
        }
	}
}

将扩展 JSON 放置在模板的根部时,资源名称包括对父虚拟机的引用。 类型反映了嵌套的配置。

{
	"type": "Microsoft.Compute/virtualMachines/extensions",
	"name": "<parentVmResource>/DAExtension",
	"apiVersion": "[variables('apiVersion')]",
	"location": "[resourceGroup().location]",
	"dependsOn": [
      "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
	],
	"properties": {
        "publisher": "Microsoft.Azure.Monitoring.DependencyAgent",
        "type": "DependencyAgentLinux",
        "typeHandlerVersion": "9.5",
        "autoUpgradeMinorVersion": true,
        "settings": {
            "enableAMA": "true"
        }
	}
}

Azure CLI 部署

可以使用 Azure CLI 将依赖项代理 VM 扩展部署到现有的虚拟机。


az vm extension set \
    --resource-group myResourceGroup \
    --vm-name myVM \
    --name DependencyAgentLinux \
    --publisher Microsoft.Azure.Monitoring.DependencyAgent \
    --version 9.5

自动扩展升级

现已提供自动升级依赖项扩展次要版本的新功能。

要为扩展启用自动扩展升级,必须确保将 enableAutomaticUpgrade 属性设置为 true 并添加到扩展模板。 必须单独在每个 VM 或 VM 规模集上启用此属性。 可使用启用部分所述的其中一种方法为 VM 或 VM 规模集启用该功能。

在 VM 或 VM 规模集中启用自动扩展升级后,每当扩展发布者发布了扩展的新版本,该扩展就会自动升级。 按照此处所述的可用性优先原则安全地应用升级。

enableAutomaticUpgrade 属性的功能与 autoUpgradeMinorVersion 不同。 扩展发布者发布新版本时,autoUpgradeMinorVersion 属性不会自动触发次要版本更新。 autoUpgradeMinorVersion 属性指示扩展是否应使用更新的次要版本(如果在部署时可用)。 但是,部署后,除非重新部署,否则扩展不会升级次要版本,即使此属性设置为 true 也是如此。

为了使扩展版本保持更新,建议对扩展部署使用 enableAutomaticUpgrade

重要

如果将 enableAutomaticUpgrade 添加到模板,请确保使用 API 2019-12-01 或更高版本。

故障排除和支持

疑难解答

有关扩展部署状态的数据可以从 Azure 门户和使用 Azure CLI 进行检索。 若要查看给定 VM 的扩展部署状态,请使用 Azure CLI 运行以下命令:

az vm extension list --resource-group myResourceGroup --vm-name myVM -o table

扩展执行输出将记录到以下文件:

/var/opt/microsoft/dependency-agent/log/install.log

支持

如果对本文中的任何内容需要更多帮助,请联系 Microsoft Q&A 和 Stack Overflow 论坛上的 Azure 专家。 或者,可以提出 Azure 支持事件。 请转到 Azure 支持站点并选择“获取支持”。 有关如何使用 Azure 支持的信息,请阅读 Microsoft Azure 支持常见问题解答