菜单
文档breadcrumb arrow Grafana Alloybreadcrumb arrow 设置breadcrumb arrow 迁移breadcrumb arrow 从 Agent Flow 迁移
开源

将 Grafana Agent Flow 迁移到 Grafana Alloy

本主题介绍如何在停机时间最短的情况下,将 Grafana Agent Flow 实时迁移到 Grafana Alloy。

注意

此过程仅适用于从 Grafana Agent Flow 安装到 Alloy 的实时迁移。

如果您想全新安装 Alloy,可以卸载 Grafana Agent Flow,然后安装 Alloy

开始之前

  • 您必须有一个要迁移的 Grafana Agent Flow 配置。
  • 您必须运行 Grafana Agent Flow v0.40 或更高版本。
  • 如果您使用自动扩缩容,请确保禁用 Grafana Agent Flow 部署的自动扩缩容功能,以防止在迁移过程中发生扩缩容。

Grafana Agent Flow 与 Alloy 之间的差异

默认情况下,您只能使用标记为“正式可用”的功能。

您可以在 run 中设置 --stability.level 标志来启用“实验性”和“公共预览”中的功能。

  • --storage.path 的默认值已从 data-agent/ 更改为 data-alloy/
  • --server.http.memory-addr 的默认值已从 agent.internal:12345 更改为 alloy.internal:12345
  • Alloy 报告的调试指标前缀为 alloy_,而不是 agent_
  • “经典模块” module.filemodule.gitmodule.httpmodule.string 已被移除,取而代之的是 import 配置块。
  • prometheus.exporter.vsphere 组件已被 otelcol.receiver.vcenter 组件取代。

步骤

准备您的 Grafana Agent Flow 配置

Alloy 使用与 Grafana Agent Flow 相同的配置格式,但一些功能已被移除。

在迁移之前,修改您的 Grafana Agent Flow 配置,移除或替换任何不受支持的组件

使用默认配置部署 Alloy

遵循 Alloy 的安装说明,使用默认配置文件。配置文件将在后续步骤中进行自定义。

部署 Alloy 时,请注意以下设置

  • 部署 Alloy 时,其拓扑结构应与 Grafana Agent Flow 相同。CPU 和存储限制应保持一致。
  • 在 Grafana Agent Flow 中配置的自定义命令行标志应在您的 Alloy 安装中反映出来。
  • 部署 Alloy 时可能需要在 run 中使用 --stability.level 标志来启用非稳定组件
    • 如果您使用以下组件,请将 --stability.level 设置为 experimental
    • 否则,可以省略 --stability.level 或将其设置为默认值 generally-available
  • 在 Kubernetes 上安装时,更新您的 values.yaml 文件,将 agent 键重命名为 alloy
  • 如果您将 Alloy 部署为集群
    • 将实例数设置为与 Grafana Agent Flow 集群中的实例数相匹配。
    • 在迁移完成之前,不要启用自动扩缩容。

将 Grafana Agent Flow 数据迁移到 Alloy

通过将 Grafana Agent Flow 数据目录的内容复制到 Alloy 数据目录来迁移您的 Grafana Agent Flow 数据。

  • Linux 安装:将 /var/lib/grafana-agent-flow内容 复制到 /var/lib/alloy/data
  • macOS 安装:将 $(brew --prefix)/etc/grafana-agent-flow/data内容 复制到 $(brew --prefix)/etc/alloy/data
  • Windows 安装:将 %ProgramData%\Grafana Agent Flow\data内容 复制到 %ProgramData%\GrafanaLabs\Alloy\data
  • Docker:将挂载卷的内容复制到新目录,然后在运行 Alloy 时挂载该目录。
  • Kubernetes:使用 kubectl cp 将 Flow Pod 上数据目录的 内容 复制到 Alloy Pod 上的数据目录。
    • 数据目录由 values.yaml 文件中的 agent.storagePath(默认 /tmp/agent)和 alloy.storagePath(默认 /tmp/alloy)字段确定。

迁移通过网络接收数据的管道

通过网络接收遥测数据的管道(例如,使用 otelcol.receiver.otlpprometheus.receive_http 的管道)应首先在 Alloy 中配置

  1. 在 Alloy 中配置所有通过网络接收遥测数据的管道。
  2. 重新配置应用程序,使其将遥测数据发送到 Alloy 而不是 Grafana Agent Flow。

迁移剩余管道

将 Grafana Agent Flow 中的剩余管道迁移到 Alloy

  1. 在 Grafana Agent Flow 中禁用剩余管道,以防止 Flow 和 Alloy 处理相同的数据。
  2. 在 Alloy 中配置剩余管道。

注意

这个过程会在将剩余管道从 Grafana Agent Flow 迁移到 Alloy 时产生最小的停机时间。

为了完全消除停机时间,请在禁用 Grafana Agent Flow 中的剩余管道之前,先在 Alloy 中配置它们。这种替代方法会导致在迁移期间向后端发送一些重复数据。

卸载 Grafana Agent Flow

完成迁移后,您可以卸载 Grafana Agent Flow。

清理临时更改

如果您在迁移过程中禁用了自动扩缩容,现在可以在 Alloy 部署中启用它。