3

I am deploying Azure Log Analytics agent to an Ubuntu 18 VM. It is done with Azure Policy by using Microsoft.EnterpriseCloud.Monitoring.OmsAgentForLinux extension. 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. I can verify the proxy settings on the monitoring agent UI in Windows OS.

I have done the same declaration for 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. Honestly, i don't know exactly where to check it on the system. And i couldn't find it on Microsoft documentation.

Does someone know how to check the proxy setting of Azure Log Analytics agent on Linux systems?

MoonHorse
  • 1,966
  • 2
  • 24
  • 46
  • You're missing the link of the microsoft documentation, please add it. – Ivan Glasenberg Mar 02 '21 at 01:14
  • Have you followed these [steps](https://learn.microsoft.com/en-us/azure/azure-monitor/agents/agent-manage#linux-agent-1)? – Nancy Mar 02 '21 at 06:27
  • @IvanYang , it is added. – MoonHorse Mar 02 '21 at 09:52
  • @NancyXiong, i have checked it but i don't have /etc/opt/microsoft/omsagent/proxy.conf file. I have also added the declaration that i use to the question. – MoonHorse Mar 02 '21 at 09:53
  • Check the value of `echo "$http_proxy"` or `echo "$https_proxy"` on Linux VM? – Nancy Mar 02 '21 at 09:58
  • @NancyXiong they are set as HTTPS_PROXY=http://123.12.13.11:80 and HTTP_PROXY=http://123.12.13.11:80 . So the important thing is to have these environment variables set? – MoonHorse Mar 04 '21 at 08:28
  • @NancyXiong , what i have seen the oms agent deployment doesn't set these environment variables. So my provisioning of the agent fails. I have also CSE deployment with another policy but it is deployed after the oms agent. – MoonHorse Mar 08 '21 at 14:59

1 Answers1

4

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. This file must be updated, and the omsagent daemon restarted, should the proxy configuration change. 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. 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.

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

Arm template:

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

enter image description here

On the Azure Linux VM,

enter image description here

Nancy
  • 26,865
  • 3
  • 18
  • 34