简体   繁体   English

Linux 系统上的 Azure Log Analytics 代理上的代理设置

[英]Proxy settings on Azure Log Analytics agent on Linux systems

I am deploying Azure Log Analytics agent to an Ubuntu 18 VM.我正在将Azure Log Analytics 代理部署到 Ubuntu 18 VM。 It is done with Azure Policy by using Microsoft.EnterpriseCloud.Monitoring.OmsAgentForLinux extension.使用Microsoft.EnterpriseCloud.Monitoring.OmsAgentForLinux扩展通过 Azure 策略完成。 I need to set proxy configuration.我需要设置代理配置。 On windows systems, the proxy setting can be set at the deployment template with "proxyUri": "[parameters('proxyUri')]" as the property of the agent.在 windows 系统上,可以在部署模板中设置代理设置,其中"proxyUri": "[parameters('proxyUri')]"作为代理的属性。 I can verify the proxy settings on the monitoring agent UI in Windows OS.我可以在 Windows OS 的监控代理 UI 上验证代理设置。

I have done the same declaration for Linux.我对 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]"
                   }
                }
             }
          ],

The agent extension is installed succesfully.代理扩展安装成功。 But in the config file /etc/opt/microsoft/omsagent/conf/omsagent.conf, i couldn't find any proxy setting.但是在配置文件 /etc/opt/microsoft/omsagent/conf/omsagent.conf 中,我找不到任何代理设置。 Honestly, i don't know exactly where to check it on the system.老实说,我不知道在系统上的确切位置。 And i couldn't find it on Microsoft documentation .而且我在Microsoft 文档中找不到它。

Does someone know how to check the proxy setting of Azure Log Analytics agent on Linux systems?有人知道如何在 Linux 系统上检查 Azure Log Analytics 代理的代理设置吗?

According to the document :根据文件

The proxy configuration is set in this file: /etc/opt/microsoft/omsagent/proxy.conf This file can be directly created or edited, but must be readable by the omsagent user.代理配置在此文件中设置: /etc/opt/microsoft/omsagent/proxy.conf此文件可以直接创建或编辑,但必须由 omsagent 用户读取。 This file must be updated, and the omsagent daemon restarted, should the proxy configuration change.如果代理配置发生更改,则必须更新此文件并重新启动 omsagent 守护程序。 For example:例如:

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

It looks like directly define proxyUri parameters in the ARM template does not work after my validation.经过我的验证,看起来直接在 ARM 模板中定义proxyUri参数不起作用。 You could try to use a custom script extension to invoke the wrapper scripts during installation.您可以尝试使用自定义脚本扩展在安装期间调用包装脚本

For example, the content of the oms_linux.sh file on an Azure storage blob.例如,Azure 存储 blob 上的oms_linux.sh文件的内容。

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

Arm template: Arm 模板:

{
  "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"

    }

  }
}

Result结果

在此处输入图像描述

On the Azure Linux VM,在 Azure Linux 虚拟机上,

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM