【问题标题】:Proxy settings on Azure Log Analytics agent on Linux systemsLinux 系统上 Azure Log Analytics 代理的代理设置
【发布时间】:2021-03-01 20:54:10
【问题描述】:

我正在将 Azure Log Analytics 代理部署到 Ubuntu 18 VM。它是通过使用 Microsoft.EnterpriseCloud.Monitoring.OmsAgentForLinux 扩展名通过 Azure Policy 完成的。我需要设置代理配置。在 Windows 系统上,代理设置可以在部署模板中设置,"proxyUri": "[parameters('proxyUri')]" 作为代理的属性。我可以在 Windows 操作系统的监控代理 UI 上验证代理设置。

我对 Linux 做了同样的声明。

          "parameters": {
             "vmName": {
                "type": "string"
             },
             "location": {
                "type": "string"
             },
             "logAnalytics": {
                "type": "string"
             },
             "proxyUri": {
                "type": "String",
                "defaultValue": "proxy_server_ipaddress",
                "metadata": {
                  "description": "Proxy Settings', Proxy Server"
                }
              }
          },
          "resources": [
             {
                "name": "[concat(parameters('vmName'),'/omsPolicy')]",
                "type": "Microsoft.Compute/virtualMachines/extensions",
                "location": "[parameters('location')]",
                "apiVersion": "2017-12-01",
                "properties": {
                   "publisher": "Microsoft.EnterpriseCloud.Monitoring",
                   "type": "OmsAgentForLinux",
                   "typeHandlerVersion": "1.13",
                   "autoUpgradeMinorVersion": true,
                   "settings": {
                      "workspaceId": "[reference(parameters('logAnalytics'), '2015-03-20').customerId]",
                      "proxyUri": "[parameters('proxyUri')]"
                   },
                   "protectedSettings": {
                      "workspaceKey": "[listKeys(parameters('logAnalytics'), '2015-03-20').primarySharedKey]"
                   }
                }
             }
          ],

代理扩展安装成功。 但是在配置文件 /etc/opt/microsoft/omsagent/conf/omsagent.conf 中,我找不到任何代理设置。老实说,我不知道在系统上的确切位置。我在Microsoft documentation 上找不到它。

有人知道如何在 Linux 系统上检查 Azure Log Analytics 代理的代理设置吗?

【问题讨论】:

  • 您缺少微软文档的链接,请添加。
  • 你关注过这些steps吗?
  • @IvanYang 已添加。
  • @NancyXiong,我已经检查过了,但我没有 /etc/opt/microsoft/omsagent/proxy.conf 文件。我还添加了我在问题中使用的声明。
  • 检查Linux VM上echo "$http_proxy"echo "$https_proxy"的值?

标签: linux azure proxy azure-log-analytics azure-vm


【解决方案1】:

根据the document

代理配置在这个文件中设置:/etc/opt/microsoft/omsagent/proxy.conf这个文件可以直接创建或编辑,但必须是omsagent用户可读的。如果代理配置发生更改,则必须更新此文件并重新启动 omsagent 守护程序。例如:

proxyconf="https://proxyuser:proxypassword@proxyserver01:8080"
sudo echo $proxyconf >>/etc/opt/microsoft/omsagent/proxy.conf
sudo chown omsagent:omiusers /etc/opt/microsoft/omsagent/proxy.conf
sudo chmod 600 /etc/opt/microsoft/omsagent/proxy.conf
sudo /opt/microsoft/omsagent/bin/service_control restart

经过我的验证,看起来直接在ARM模板中定义proxyUri参数不起作用。您可以尝试在安装过程中使用custom script extension 来调用wrapper scripts

例如,Azure 存储 Blob 上 oms_linux.sh 文件的内容。

sudo sh ./onboard_agent.sh -p https://<proxy address>:<proxy port> -w <workspace id> -s <shared key>

手臂模板:

{
  "type": "Microsoft.Compute/virtualMachines/extensions",
  "name": "[concat(parameters('vmName'),'/installcustomscript')]",
  "apiVersion": "2019-03-01",
  "location": "[parameters('location')]",
  "properties": {
    "publisher": "Microsoft.Azure.Extensions",
    "type": "CustomScript",
    "typeHandlerVersion": "2.1",
    "autoUpgradeMinorVersion": true,
    "settings": {
      "fileUris": ["https://mystorageaccount.blob.core.windows.net/oms/oms_linux.sh"]
  
    },
    "protectedSettings": {

     "commandToExecute": "wget https://raw.githubusercontent.com/Microsoft/OMS-Agent-for-Linux/master/installer/scripts/onboard_agent.sh && sh oms_linux.sh",
      "storageAccountName": "xxx",
      "storageAccountKey": "xxxx"

    }

  }
}

结果

在 Azure Linux VM 上,

【讨论】:

    猜你喜欢
    • 2021-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-03
    • 2015-02-19
    • 2011-05-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多