4
votes

Hi I am trying to create an ARM template to setup the Azure Linux Diagnostic extension on my Linux VM using ARM templates to monitor mount points.

I am referring to the following documentation to achieve the same:

https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-template

However, on researching through other documentation provided by Microsoft, I figured out that the Windows and the Linux Diagnostic agent have different monitoring params.

Windows: https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-windows

Linux:https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-linux

The ARM JSON for Windows is:

"resources": [
    {
        "name": "Microsoft.Insights.VMDiagnosticsSettings",
        "type": "extensions",
        "location": "[resourceGroup().location]",
        "apiVersion": "2015-06-15",
        "dependsOn": [
            "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
        ],
        "tags": {
            "displayName": "AzureDiagnostics"
        },
        "properties": {
            "publisher": "Microsoft.Azure.Diagnostics",
            "type": "IaaSDiagnostics",
            "typeHandlerVersion": "1.5",
            "autoUpgradeMinorVersion": true,
            "settings": {
                "xmlCfg": "[base64(concat(variables('wadcfgxstart'), variables('wadmetricsresourceid'), variables('vmName'), variables('wadcfgxend')))]",
                "storageAccount": "[parameters('existingdiagnosticsStorageAccountName')]"
            },
            "protectedSettings": {
                "storageAccountName": "[parameters('existingdiagnosticsStorageAccountName')]",
                "storageAccountKey": "[listkeys(variables('accountid'), '2015-05-01-preview').key1]",
                "storageAccountEndPoint": "https://core.windows.net"
            }
        }
    }
]

Would anyone know what would be the "settings" and "protectedSettings" for Linux Diagnostic Agent for Linux?

2
so eh, whats wrong with the link you posted, it has all the settings?4c74356b41
I am assuming there would be no xmlcfg for Linux. If you see the variables it has wadcfgxstart, wadmetricsresourceid, etc which is exclusive to windows and not LInux. Linux uses LAD.Akash Masand

2 Answers

5
votes

I am answering my own question here.

The differences when comparing the same with the Azure Diagnostic agent for Windows is:

  1. type which is under properties. This will correspond to LinuxDiagnostic and not IaaSDiagnostics.
  2. typehandlerversion: This is basically the LAD version. The latest one is 3.0.
  3. protectedSettings: This can be written in the following way:

    { "storageAccountName" : "the storage account to receive data", "storageAccountEndPoint": "the hostname suffix for the cloud for this account", "storageAccountSasToken": "SAS access token", "mdsdHttpProxy": "HTTP proxy settings", "sinksConfig": { ... } }

The mdsdHttpProxy and the sinksConfig parameters are optional and need to be configured only if the settings for the same have been made. More information on this can be found here (in the protected settings section).

  1. settings: This will take the following form:

    { "ladCfg": { ... }, "perfCfg": { ... }, "fileLogs": { ... }, "StorageAccount": "the storage account to receive data", "mdsdHttpProxy" : "" }

Each of these have been discussed in detail here (in public settings).

An example of the Linux Diagnostic extension that worked for me is as follows:

"resources": [
    {
      "type": "Microsoft.Compute/virtualMachines/extensions",
      "apiVersion": "2017-12-01",
      "location": "[resourceGroup().location]",
      "name": "[concat(variables('vmName'), '/Microsoft.Insights.VMDiagnosticSettings')]",
      "tags": {
        "displayName": "AzureDiagnostics"
      },
      "properties": {
        "publisher": "Microsoft.Azure.Diagnostics",
        "type": "LinuxDiagnostic",
        "autoUpgradeMinorVersion": true,
        "typeHandlerVersion": "3.0",
        "protectedSettings": {
          "storageAccountName": "[parameters('storageAccountName')]",
          "storageAccountEndPoint": "https://core.windows.net",
          "storageAccountSasToken": "[parameters('sasToken')]"
        },
        "settings": {
          "StorageAccount": "[parameters('storageAccountName')]",
          "ladCfg": {
            "diagnosticMonitorConfiguration": {
              "syslogEvents": {},
              "sampleRateInSeconds": 15,
              "eventVolume": "Medium",
              "metrics": {
                "resourceId": "[resourceId('Microsoft.Compute/virtualMachines', variables('vmName'))]",
                "metricAggregation": [
                  { "scheduledTransferPeriod": "PT1H" },
                  { "scheduledTransferPeriod": "PT1M" }
                ]
              },
              "performanceCounters": {
                "performanceCounterConfiguration": [
                  {
                    "annotation": [
                      {
                        "displayName": "Filesystem % free space",
                        "locale": "en-us"
                      }
                    ],
                    "class": "filesystem",
                    "condition": "IsAggregate=TRUE",
                    "counter": "percentfreespace",
                    "counterSpecifier": "/builtin/filesystem/percentfreespace",
                    "type": "builtin",
                    "unit": "Percent"
                  },
                  {
                    "annotation": [
                      {
                        "displayName": "Filesystem % used space",
                        "locale": "en-us"
                      }
                    ],
                    "class": "filesystem",
                    "condition": "IsAggregate=TRUE",
                    "counter": "percentusedspace",
                    "counterSpecifier": "/builtin/filesystem/percentusedspace",
                    "type": "builtin",
                    "unit": "Percent"
                  },
                  {
                    "annotation": [
                      {
                        "displayName": "Filesystem used space",
                        "locale": "en-us"
                      }
                    ],
                    "class": "filesystem",
                    "condition": "IsAggregate=TRUE",
                    "counter": "usedspace",
                    "counterSpecifier": "/builtin/filesystem/usedspace",
                    "type": "builtin",
                    "unit": "Bytes"
                  },
                  {
                    "annotation": [
                      {
                        "displayName": "Filesystem read bytes/sec",
                        "locale": "en-us"
                      }
                    ],
                    "class": "filesystem",
                    "condition": "IsAggregate=TRUE",
                    "counter": "bytesreadpersecond",
                    "counterSpecifier": "/builtin/filesystem/bytesreadpersecond",
                    "type": "builtin",
                    "unit": "CountPerSecond"
                  },
                  {
                    "annotation": [
                      {
                        "displayName": "Filesystem free space",
                        "locale": "en-us"
                      }
                    ],
                    "class": "filesystem",
                    "condition": "IsAggregate=TRUE",
                    "counter": "freespace",
                    "counterSpecifier": "/builtin/filesystem/freespace",
                    "type": "builtin",
                    "unit": "Bytes"
                  },
                  {
                    "annotation": [
                      {
                        "displayName": "Filesystem % free inodes",
                        "locale": "en-us"
                      }
                    ],
                    "class": "filesystem",
                    "condition": "IsAggregate=TRUE",
                    "counter": "percentfreeinodes",
                    "counterSpecifier": "/builtin/filesystem/percentfreeinodes",
                    "type": "builtin",
                    "unit": "Percent"
                  }
                ]
              }
            }
          }
        }
      }
    }
  ]
0
votes
# Download the sample Public settings. (You could also use curl or any web browser)
wget https://raw.githubusercontent.com/Azure/azure-linux-extensions/master/Diagnostic/tests/lad_2_3_compatible_portal_pub_settings.json -O portal_public_settings.json

# Build the VM resource ID. Replace storage account name and resource ID in the public settings.
my_vm_resource_id=$(az vm show -g $my_resource_group -n $my_linux_vm --query "id" -o tsv)
sed -i "s#__DIAGNOSTIC_STORAGE_ACCOUNT__#$my_diagnostic_storage_account#g" portal_public_settings.json
sed -i "s#__VM_RESOURCE_ID__#$my_vm_resource_id#g" portal_public_settings.json

# Build the protected settings (storage account SAS token)
my_diagnostic_storage_account_sastoken=$(az storage account generate-sas --account-name $my_diagnostic_storage_account --expiry 2037-12-31T23:59:00Z --permissions wlacu --resource-types co --services bt -o tsv)
my_lad_protected_settings="{'storageAccountName': '$my_diagnostic_storage_account', 'storageAccountSasToken': '$my_diagnostic_storage_account_sastoken'}"

# Finallly tell Azure to install and enable the extension
az vm extension set --publisher Microsoft.Azure.Diagnostics --name LinuxDiagnostic --version 3.0 --resource-group $my_resource_group --vm-name $my_linux_vm --protected-settings "${my_lad_protected_settings}" --settings portal_public_settings.json

protected settings map to protected settings in json. that json file should map to the non protected settings

if you read the article it also tells you how to configure other things like sinks\counters\etc