用于配置诊断设置的Azure Gateway ARM模板(Log Analytics工作区)

时间:2020-05-15 09:55:18

标签: azure arm-template azure-log-analytics azure-diagnostics azure-application-gateway

我正在寻找有助于配置(日志分析)诊断设置的ARM模板。搜索的模板很少,但没有希望。尝试通过导出模板以及在资源浏览器中找不到诊断设置配置。请分享您的想法

这是我正在尝试的ARM模板

"apiVersion": "2015-07-01",
         "name": "[concat(parameters('applicationGateways_name'), '/Microsoft.Insights/service')]",
         "type": "Microsoft.Network/applicationGateways/providers/diagnosticsettings",
         "location": "[resourceGroup().location]",
          "dependsOn": [
            "[concat('Microsoft.Network/ApplicationGateways/', parameters('applicationGateways_name'))]"
          ],
          "properties":{
            "name":"DiagService",
            "workspaceId":"[variables('workspaceId')]",
            "logs":[
               {

“类型”为:“ Microsoft.Network/applicationGateways/提供者/诊断设置” 不扣除

我试图在现有工作区中添加

2 个答案:

答案 0 :(得分:1)

它进行了以下更改

{
   "apiVersion": "2017-05-01-preview",
   "name": "[concat(parameters('applicationGatewayName'), '/Microsoft.Insights/diagnosticSettings')]",
   "type":"Microsoft.Network/applicationGateways/providers/diagnosticSettings",
   "location": "[resourceGroup().location]",
   "dependsOn": [
        "[concat('Microsoft.Network/ApplicationGateways/', parameters('applicationGatewayName'))]"
      ],
      "properties":{
        "name":"Diag",
        "workspaceId":  "[concat('/subscriptions/', subscription().subscriptionId,  '/resourceGroups/', resourceGroup().name, '/providers/microsoft.operationalinsights/workspaces/', parameters('workspaceId'))]",


        "logs":[
           {
             "category": "ApplicationGatewayAccessLog",
             "enabled": true,
             "retentionPolicy": {
             "enabled": false,
             "days": 0
                                }
           },
           {
              "category": "ApplicationGatewayPerformanceLog",
              "enabled": true,
              "retentionPolicy": {
                "days": 0,
                "enabled": false
              }
            },
            {
              "category": "ApplicationGatewayFirewallLog",
              "enabled": true,
              "retentionPolicy": {
                "days": 0,
                "enabled": false
              }
            }
                ],
                "metrics": [
            {
              "category": "AllMetrics",
              "enabled": true,
              "retentionPolicy": {
                "enabled": false,
                "days": 0
              }
            }
          ]
                    }
  }

请注意,这里我使用了先前创建的通用工作区

答案 1 :(得分:0)

ARM模板缺少要发送到工作空间的哪种日志/度量。尝试在您的部分中添加它:

   "logs": [
      {
        "category": "ApplicationGatewayAccessLog",
        "enabled": true,
        "retentionPolicy": {
          "enabled": false,
          "days": 0
        }
      },
      {
        "category": "ApplicationGatewayPerformanceLog",
        "enabled": true,
        "retentionPolicy": {
          "enabled": false,
          "days": 0
        }
      },
      {
        "category": "ApplicationGatewayFirewallLog",
        "enabled": true,
        "retentionPolicy": {
          "enabled": false,
          "days": 0
        }
      }
    ],
    "metrics": [
      {
        "category": "AllMetrics",
        "timeGrain": "PT1M",
        "enabled": true,
        "retentionPolicy": {
          "enabled": false,
          "days": 0
        }

      }
    ]

根据需要编辑保留。