Proxy settings on Azure Log Analytics agent on Linux systems

Viewed 1236

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?

1 Answers

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

Related