在 Linux 台计算机中安装 Log Analytics Agent 时工作区密钥不正确

incorrect workspace key while installing Log Analytics Agent in Linux machine

我在 Azure 云上的 Linux 机器上部署 Log Analytics Agent 时遇到了这个问题。

Enable failed with exit code 53 Installation failed due to incorrect workspace key. Please check if the workspace key is correct. For details, check logs in /var/log/azure/Microsoft.EnterpriseCloud.Monitoring.OmsAgentForLinux/extension.log

我使用了 terraform 脚本。

resource "azurerm_virtual_machine_extension" "log_analytic_agent" {
  name                       = "Log-Analytic-Agent-Extension"
  virtual_machine_id         =  module.machine.vm_id

  publisher                     = "Microsoft.EnterpriseCloud.Monitoring"
  type                          = "OmsAgentForLinux"
  type_handler_version          = "1.6"
  auto_upgrade_minor_version    = true


  settings = <<SETTINGS
    {
      "workspaceId" : "1323232323232323"
    }
  SETTINGS

  protected_settings = <<PROTECTED_SETTINGS
    {
      "workspaceKey" : "dsdsdsfd434fdvdghtcDW#efggrgrffefef"
    }
  PROTECTED_SETTINGS


}

刚刚弄明白,上面报错的原因

为了在 linux 机器上安装日志分析代理,我们应该启用从机器到这些机器的出站访问权限:

*.ods.opinsights.azure.com  Port 443    Outbound    
*.oms.opinsights.azure.com  Port 443    Outbound
*.blob.core.windows.net     Port 443    Outbound
*.azure-automation.net      Port 443    Outbound