Skip to content
Advertisement

Setup Linux Diagnostic extension using ARM templates

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://learn.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://learn.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-windows

Linux:https://learn.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?

Advertisement

Answer

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"
                  }
                ]
              }
            }
          }
        }
      }
    }
  ]
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement