Azure 監視器虛擬機器深入解析中的 Dependency Agent

Important

VM Insights 中的相依代理與地圖體驗已被棄用,將於 2028 年 6 月 30 日正式退休。 如需詳細資訊,請參閱 我們的淘汰指引

相依性代理程式會收集虛擬機上執行的進程及其外部進程相依性的相關數據。 更新包括 Bug 修正或新功能的支援。 本文描述 Dependency Agent 的需求,以及如何手動或透過自動化方式升級該代理程式。

Note

Dependency Agent 會將活動訊號資料傳送至 InsightsMetrics 資料表,因此您會產生資料擷取費用。 此行為與監控代理Azure不同,後者會將代理健康資料傳送至Heartbeat表格,且該表不需支付資料收集費用。

Dependency Agent 需求

  • Azure Monitor 代理程式必須安裝在同一台機器上。
  • 需要從虛擬機器連線至位址 169.254.169.254。 此位址識別 Azure 元資料服務端點。

受支援的作業系統

相依代理目前支援到 Windows Server 2022 的 Windows 版本,與 Azure 監控代理相同,但不支援 Azure Stack HCI 和 Windows IoT Enterprise。 不支援 Windows Server Core。 相依性代理程式僅支援 x64 架構。

在 Linux 電腦上安裝相依性代理程式之前,請考慮下列事項:

  • 只支援預設版本和 SMP Linux 核心版本。
  • 所有 Linux 散發套件皆不支援非標準的核心版本,例如實體位址擴充 (PAE) 和 Xen。 例如,不支援版本字串為 2.6.16.21-0.8-xen 的系統。
  • 不支援自訂核心,包括重新編譯的標準核心。
  • 對於 9.4 版以外的 Debian 散發版本,不支援對應功能。 效能功能僅能從 Azure Monitor 選單中取得。 它無法直接從 Azure 虛擬機的左側窗格取得。
  • 安裝相依性代理程式會損及 Linux 核心,而且您可能會失去 Linux 發行版的支援,直到機器重設為止。

必須針對 Spectre 和 Meldown 弱點修補 Linux 核心。 如需更多資訊,請洽詢 Linux 發行版供應商。 執行下列命令,即可檢查是否已緩解 Spectre/Meldown 相關問題:

$ grep . /sys/devices/system/cpu/vulnerabilities/*

此命令的輸出看起來與下列內容相似,且說明機器是否易受任一問題的影響。 如果遺失這些檔案,機器就無法修補。

/sys/devices/system/cpu/vulnerabilities/meltdown:Mitigation: PTI
/sys/devices/system/cpu/vulnerabilities/spectre_v1:Vulnerable
/sys/devices/system/cpu/vulnerabilities/spectre_v2:Vulnerable: Minimal generic ASM retpoline

安裝或升級 Dependency Agent

Note

在機器上啟用 VM Insights 以進行進程和連線數據時,會自動安裝相依性代理程式。 如果僅針對效能資料啟用 VM Insights,則不會安裝 Dependency Agent。

您可以使用下列方法,根據執行機器的部署案例和環境,手動或自動升級適用於 Windows 和 Linux 的 Dependency Agent:

Environment 安裝方法 升級方法
Azure VM 適用於 WindowsLinux 的 Dependency Agent 虛擬機器擴充功能 除非你在 Azure Resource Manager 範本中將屬性 autoUpgradeMinorVersion 設為 false,否則代理程式預設會自動升級。 次要版本 (停用自動升級) 及主要版本的升級依循相同方法:解除安裝並重新安裝延伸模組。
自訂 Azure 虛擬機器映像檔 手動安裝適用於 Windows/Linux 的 Dependency Agent 要將虛擬機器 (VMs) 更新為最新版本的代理程式,需透過命令列執行 Windows 安裝套件或 Linux 自解壓縮且可安裝的殼層指令碼包進行操作。
非Azure虛擬機器 手動安裝適用於 Windows/Linux 的 Dependency Agent 要將虛擬機器 (VMs) 更新為最新版本的代理程式,需透過命令列執行 Windows 安裝套件或 Linux 自解壓縮且可安裝的殼層指令碼包進行操作。

在 Windows 上手動安裝或升級 Dependency Agent

使用指令碼或其他自動化解決方案,或使用InstallDependencyAgent-Windows.exe 安裝精靈,從命令提示字元更新 Windows VM 上的代理程式。

Prerequisites

使用安裝精靈

  1. 以具有系統管理權限的帳戶登入電腦。

  2. 執行 InstallDependencyAgent-Windows.exe 啟動安裝精靈。

  3. 依循 [Dependency Agent 安裝] 精靈解除安裝舊版的 Dependency Agent,並安裝最新版本。

從命令列

  1. 使用具有系統管理權限的帳戶登入電腦。

  2. 執行以下命令:

    InstallDependencyAgent-Windows.exe /S /RebootMode=manual
    

    若某些流程使用並鎖定舊版的檔案,/RebootMode=manual 參數會讓升級時無法自動重新開機。

  3. 若要確認升級成功,請查看 install.log 以取得詳細的安裝資訊。 記錄目錄是 %Programfiles%\Microsoft Dependency Agent\logs

在 Linux 上手動安裝或升級 Dependency Agent

Linux Dependency Agent 舊版本的升級是被支援的,且使用與全新安裝相同的命令來執行。

Prerequisites

curl -L -o DependencyAgent-Linux64.bin https://aka.ms/dependencyagentlinux

Note

Curl 不會自動設定執行權限。 您必須使用 chmod 進行手動設定:

chmod +x DependencyAgent-Linux64.bin

從命令列

  1. 使用具有 sudo 權限,能夠以 root 身分執行命令的使用者帳戶登入電腦。

  2. 執行以下命令:

    sudo <path>/InstallDependencyAgent-Linux64.bin
    

如果 Dependency Agent 無法啟動,請檢查記錄以取得詳細的錯誤資訊。 在 Linux 代理程式上,記錄檔的目錄是 /var/opt/microsoft/dependency-agent/log

解除安裝 Dependency Agent

Note

如果是手動安裝 Dependency Agent,它不會顯示在 Azure portal 裡,必須手動卸載。 只有透過 Azure portalPowerShellARM 模板部署,或 Azure policy 安裝時才會顯示。

  1. 在Azure portal的 Virtual Machines 選單中,選擇你的虛擬機器。

  2. 選取 [擴充功能 + 應用程式]> [DependencyAgentWindows] 或 [DependencyAgentLinux]> [解除安裝]

    截圖顯示虛擬機器的擴充功能與應用程式畫面。

在 Windows 上手動解除安裝 Dependency Agent

方法 1:在 Windows 中,移至 [新增和移除程式]、尋找Microsoft Dependency Agent,按一下省略號以開啟捷徑功能表,然後選取 [解除安裝]

方法 2:使用位於 Microsoft Dependency Agent 資料夾中的解除安裝程式,例如 C:\Program Files\Microsoft Dependency Agent"\Uninstall_v.w.x.y.exe (其中 v.w.x.y 是版本號碼)。

在 Linux 上手動解除安裝 Dependency Agent

  1. 使用具有 sudo 權限,能夠以 root 身分執行命令的使用者帳戶登入電腦。

  2. 執行以下命令:

    sudo /opt/microsoft/dependency-agent/uninstall -s
    

Dependency Agent Linux 支援

由於 Dependency Agent 可在核心層級運作,因此支援也會相依於核心版本。 從 Dependency Agent 9.10.* 版起,代理程式支援 * 個核心。 下表列出 Dependency Agent 的主要和次要 Linux OS 版本和支援的核心版本。

Note

使用 Dependency Agent 9.10.15 和更新版本時,不會針對不支援的核心版本封鎖安裝,但代理程式會以降級模式執行。 在此模式中,不會收集儲存在 VMConnection 和 VMBoundport 資料表中的連線和連接埠資料。 VMProcess 資料表可能會有一些資料,但會是最少量的資料。

Distribution 操作系統版本 核心版本
紅帽 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
紅帽 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
紅帽 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 服務器 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 企業伺服器 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 企業伺服器 15 SP1 4.12.14-197.-default, 4.12.14-8.-azure
15 4.12.14-150.*-default
Debian 9 4.9

Note

依賴代理程式不支援搭載 Ampere Altra ARM 處理器的 Azure Virtual Machines。

後續步驟

若要停止監視 VM 一段時間或完全移除 VM 深入解析,請參閱在 VM 深入解析中停用 VM 的監視