用于从 Log Analytics 代理迁移到 Azure Monitor 代理的工具

Azure Monitor 代理 (AMA)会替换 Windows 和 Linux 计算机的 Log Analytics 代理(也称为 MMA 和 OMS),不管是在 Azure 环境中还是在非 Azure 环境(本地和第三方云)中。 迁移到 Azure Monitor 代理的好处包括增强的安全性、成本效益、性能、易管理性和可靠性。 本文介绍如何使用 AMA 迁移帮助程序和 DCR 配置生成器工具来帮助自动化和跟踪从 Log Analytics 代理到 Azure Monitor 代理的迁移。

Flow diagram that shows the steps involved in agent migration and how the migration tools help in generating DCRs and tracking the entire migration process.

重要

不要删除其他Azure 解决方案或服务正在使用的旧版代理程序。 使用迁移帮助程序以发现当前使用的解决方案/服务。

重要

旧版 Log Analytics 代理将于 2024 年 8 月弃用。 在此日期之后,Azure 将不再为 Log Analytics 代理提供任何支持。 请在 2024 年 8 月之前迁移到 Azure Monitor 代理,这样才能继续引入数据。

使用 AMA 迁移帮助程序

AMA 迁移帮助程序是一个基于工作簿的 Azure Monitor 解决方案,可帮助你发现要迁移的内容,并在从 Log Analytics 代理迁移到 Azure Monitor 代理的过程中跟踪进度。 使用这单个界面可以加速代理迁移旅程并跟踪其状态。 帮助程序现在支持多个订阅,且包含基于使用情况的自动迁移建议。

可以在此处访问工作簿,也可以在 Azure 门户上的“监视”>“工作簿”>“公共模板”>“Azure Monitor 基本信息”>“AMA 迁移帮助程序”下找到它。

Screenshot of the Azure Monitor Agent Migration Helper workbook. The screenshot highlights the Subscription and Workspace dropdowns and shows the Azure Virtual Machines tab, on which you can track which agent is deployed on each virtual machine.

自动迁移建议

Screenshot of the Azure Monitor Agent Migration Helper workbook. The screenshot highlights the automatic migration recommendations based on sample usage across machines within selected scope.

安装和使用 DCR 配置生成器

Azure Monitor 代理仅依赖于使用数据收集规则 (DCR) 进行配置,而 Log Analytics 代理则是从 Log Analytics 工作区继承其配置。

使用 DCR 配置生成器工具分析工作区中的 Log Analytics 代理配置,并自动生成/部署相应的数据收集规则。 然后,可以使用内置的关联策略将规则关联到运行新代理的计算机。

注意

DCR 配置生成器目前不支持依赖于 Log Analytics 代理的 Azure 解决方案或服务的其他配置。

先决条件\设置

  1. 建议使用 Powershell version 7.1.3 或更高版本(最低版本 5.1)
  2. 使用 Az Powershell module 拉取工作区代理配置信息 Az PowerShell 模块
  3. 用户需要对指定的工作区资源具有读/写访问权限
  4. Connect-AzAccount 和 Select-AzSubscription 将用于设置脚本运行的上下文,因此需要适当的 Azure 凭据

若要安装 DCR 配置生成器,请执行以下操作:

  1. 下载 PowerShell 脚本

  2. 使用以下示例参数运行脚本:

     .\WorkspaceConfigToDCRMigrationTool.ps1 -SubscriptionId $subId -ResourceGroupName $rgName -WorkspaceName $workspaceName -DCRName $dcrName -OutputFolder $outputFolderPath
    

    名称 必需 说明
    SubscriptionId 这是工作区的订阅 ID
    ResourceGroupName 这是工作区的资源组
    WorkspaceName 这是工作区的名称(Azure 资源 ID 不区分大小写)
    DCRName 将用于每个输出 DCR 的基础名称
    OutputFolder NO 输出文件夹路径。 如果未提供,则使用工作目录路径
  3. 输出:

    对于每个受支持的 DCR type,脚本将生成 DCR ARM 模板(准备好部署)和 DCR 有效负载(对于不需要 ARM 模板的用户)。 这是当前支持的 DCR 类型列表:

    • Windows 仅包含 WindowsPerfCountersWindowsEventLogs 数据源
    • Linux 仅包含 LinuxPerfCountersSyslog 数据源
    • 自定义日志仅包含 logFiles 数据源:
      • 每个自定义日志都有自己的 DCR ARM 模板
    • IIS 日志仅包含 iisLogs 数据源
    • 扩展仅包含 extensions 数据源以及任何关联的 perfCounters 数据源
      • VMInsights - 如果要添加对新扩展类型的支持,请联系我们。
  4. 部署生成的 ARM 模板:

    Portal

    • 在门户的搜索框中,输入“模板”,然后选择“部署自定义模板”。

      Screenshot of the Deploy custom template screen.

    • 选择“在编辑器中生成自己的模板”。

      Screenshot of the template editor.

    • 将生成的模板粘贴到编辑器中,然后选择“保存”。

    • 在“自定义部署”屏幕中,指定“订阅”、“资源组”和“区域”。

    • 选择“查看 + 创建”>“创建”。

    PowerShell

     New-AzResourceGroupDeployment -ResourceGroupName <resource-group-name> -TemplateFile <path-to-template>
    

    注意

    在数据收集规则中最多可以包含 100 个“counterSpecifiers”。 “samplingFrequencyInSeconds”必须介于 1 和 300 之间(包括)。

  5. 将计算机关联到数据收集规则:

    1. 在的“监视”菜单中,选择“数据收集规则”。
    2. 从“数据收集规则”屏幕中选择数据收集规则。
    3. 选择“查看资源>”“添加”。
    4. 选择计算机“>应用”。