使用 ARM 模板设置 Linux 诊断扩展

Aka*_*and 4 linux azure azure-resource-manager azure-rm-template

您好,我正在尝试创建一个 ARM 模板,以使用 ARM 模板在我的 Linux VM 上设置 Azure Linux 诊断扩展来监视挂载点。

我指的是以下文档来实现相同的目的:

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

但是,通过研究 Microsoft 提供的其他文档,我发现 Windows 和 Linux 诊断代理具有不同的监视参数。

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

Windows 的 ARM JSON 是:

"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"
            }
        }
    }
]
Run Code Online (Sandbox Code Playgroud)

有谁知道Linux Diagnostic Agent for Linux的“ settings”和“ protectedSettings”是什么?

Aka*_*and 5

我在这里回答我自己的问题。

与适用于 Windows 的 Azure 诊断代理进行比较时的不同之处在于:

  1. type这是在properties. 这将对应于LinuxDiagnostic而不是IaaSDiagnostics
  2. typehandlerversion: 这基本上是 LAD 版本。最新的一个是3.0
  3. protectedSettings: 可以这样写:

    { "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": { ... } }

mdsdHttpProxy 和 sinksConfig 参数是可选的,只有在进行了相同设置时才需要配置。可以在此处找到更多信息(在受保护的设置部分)。

  1. settings:这将采用以下形式:

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

此处(在公共场合)已详细讨论了其中的每一个。

对我有用的 Linux 诊断扩展的示例如下:

"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"
                  }
                ]
              }
            }
          }
        }
      }
    }
  ]
Run Code Online (Sandbox Code Playgroud)