使用Windows Azure 診斷擴充功能的效能監控

本文件涵蓋透過 Windows Azure 診斷(WAD)擴充套件為 Windows 叢集設置效能計數器收集所需的步驟。 對於 Linux 叢集,請設定 Azure 監視器 Agent 和資料收集規則,來收集節點的效能計數器。

Note

WAD 擴充功能應該部署在你的叢集上,這些步驟才會對你有效。 如果尚未設定,請前往使用 Windows Azure 診斷 進行事件彙總與收集。

Note

建議您使用 Azure Az PowerShell 模組來與 Azure 互動。 若要開始使用,請參閱安裝 Azure PowerShell。 若要了解如何移轉至 Az PowerShell 模組,請參閱將 Azure PowerShell 從 AzureRM 移轉至 Az。

透過 WadCfg 收集效能計數器

要透過 WAD 收集效能計數器,你需要在叢集的 Resource Manager 範本中適當修改設定。 請依照以下步驟將你想收集的效能計數器加入範本,並執行 Resource Manager 資源升級。

  1. 在你叢集的範本中找到 WAD 配置 - 找到 WadCfg。 你將新增效能計數器,以在 DiagnosticMonitorConfiguration 下收集資料。

  2. 設定組態,以便在 DiagnosticMonitorConfiguration 中加入下列區段,並收集效能計數器。

    "PerformanceCounters": {
        "scheduledTransferPeriod": "PT1M",
        "PerformanceCounterConfiguration": []
    }
    

    scheduledTransferPeriod 定義了所收集的計數器值,會以何種頻率傳輸至您的 Azure 儲存體以及任何已設定的匯出端。

  3. 將您想要收集的效能計數器新增至上一步驟中宣告的 PerformanceCounterConfiguration 中。 你想收集的每個計數器都以 counterSpecifier、 sampleRate、 unit、 annotation及任何相關的 sinks定義。

這裡有一個設定範例,包含總處理器時間(CPU 用於處理操作的時間)與 Service Fabric 演員方法呼叫次數每秒,後者是 Service Fabric 的自訂效能計數器之一。 請參閱 Reliable Actor Performance Counters 和 Reliable Service Performance Counters,以取得 Service Fabric 自訂效能計數器的完整清單。

"WadCfg": {
        "DiagnosticMonitorConfiguration": {
          "overallQuotaInMB": "50000",
          "EtwProviders": {
            "EtwEventSourceProviderConfiguration": [
              {
                "provider": "Microsoft-ServiceFabric-Actors",
                "scheduledTransferKeywordFilter": "1",
                "scheduledTransferPeriod": "PT5M",
                "DefaultEvents": {
                  "eventDestination": "ServiceFabricReliableActorEventTable"
                }
              },
              {
                "provider": "Microsoft-ServiceFabric-Services",
                "scheduledTransferPeriod": "PT5M",
                "DefaultEvents": {
                  "eventDestination": "ServiceFabricReliableServiceEventTable"
                }
              }
            ],
            "EtwManifestProviderConfiguration": [
              {
                "provider": "cbd93bc2-71e5-4566-b3a7-595d8eeca6e8",
                "scheduledTransferLogLevelFilter": "Information",
                "scheduledTransferKeywordFilter": "4611686018427387904",
                "scheduledTransferPeriod": "PT5M",
                "DefaultEvents": {
                  "eventDestination": "ServiceFabricSystemEventTable"
                }
              }
            ]
          },
          "PerformanceCounters": {
                "scheduledTransferPeriod": "PT1M",
                "PerformanceCounterConfiguration": [
                    {
                        "counterSpecifier": "\\Processor(_Total)\\% Processor Time",
                        "sampleRate": "PT1M",
                        "unit": "Percent",
                        "annotation": [
                        ],
                        "sinks": ""
                    },
                    {
                        "counterSpecifier": "\\Service Fabric Actor Method(*)\\Invocations/Sec",
                        "sampleRate": "PT1M",
                    }
                ]
            }
        }
      },

計數器的取樣率可以依需求調整。 因為格式為 PT<time><unit>,如果想每秒收集一次計數器,就應該設定 "sampleRate": "PT15S"。

你也可以在 ARM 範本中使用變數收集一系列效能計數器,這在收集每個程序效能計數器時會很有用。 以下範例中,我們收集每個程序的處理器時間與記憶體回收時間,接著收集本身全部使用變數之節點的兩個效能計數器。

"variables": {
  "copy": [
      {
        "name": "processorTimeCounters",
        "count": "[length(parameters('monitoredProcesses'))]",
        "input": {
          "counterSpecifier": "\\Process([parameters('monitoredProcesses')[copyIndex('processorTimeCounters')]])\\% Processor Time",
          "sampleRate": "PT1M",
          "unit": "Percent",
          "sinks": "applicationInsights",
          "annotation": [
            {
              "displayName": "[concat(parameters('monitoredProcesses')[copyIndex('processorTimeCounters')],' Processor Time')]",
              "locale": "en-us"
            }
          ]
        }
      },
      {
        "name": "gcTimeCounters",
        "count": "[length(parameters('monitoredProcesses'))]",
        "input": {
          "counterSpecifier": "\\.NET CLR Memory([parameters('monitoredProcesses')[copyIndex('gcTimeCounters')]])\\% Time in GC",
          "sampleRate": "PT1M",
          "unit": "Percent",
          "sinks": "applicationInsights",
          "annotation": [
            {
              "displayName": "[concat(parameters('monitoredProcesses')[copyIndex('gcTimeCounters')],' Time in GC')]",
              "locale": "en-us"
            }
          ]
        }
      }
    ],
    "machineCounters": [
      {
        "counterSpecifier": "\\Memory\\Available Bytes",
        "sampleRate": "PT1M",
        "unit": "KB",
        "sinks": "applicationInsights",
        "annotation": [
          {
            "displayName": "Memory Available Kb",
            "locale": "en-us"
          }
        ]
      },
      {
        "counterSpecifier": "\\Memory\\% Committed Bytes In Use",
        "sampleRate": "PT15S",
        "unit": "percent",
        "annotation": [
          {
            "displayName": "Memory usage",
            "locale": "en-us"
          }
        ]
      }
    ]
  }
....
"WadCfg": {
    "DiagnosticMonitorConfiguration": {
      "overallQuotaInMB": "50000",
      "Metrics": {
        "metricAggregation": [
          {
            "scheduledTransferPeriod": "PT1M"
          }
        ],
        "resourceId": "[resourceId('Microsoft.Compute/virtualMachineScaleSets', variables('vmNodeTypeApp2Name'))]"
      },
      "PerformanceCounters": {
        "scheduledTransferPeriod": "PT1M",
        "PerformanceCounterConfiguration": "[concat(variables ('processorTimeCounters'), variables('gcTimeCounters'),  variables('machineCounters'))]"
      },
....
  1. 當你新增需要收集的適當效能計數器後,你需要升級叢集資源,讓這些變更反映在你正在執行的叢集中。 儲存你修改過的 template.json,然後開啟 PowerShell。 你可以使用 New-AzResourceGroupDeployment 升級叢集。 呼叫需要資源群組名稱、更新後的範本檔案和參數檔案,並提示 Resource Manager 對你更新的資源做適當的修改。 登入帳號並加入正確的訂閱後,請使用以下指令執行升級:

    New-AzResourceGroupDeployment -ResourceGroupName <ResourceGroup> -TemplateFile <PathToTemplateFile> -TemplateParameterFile <PathToParametersFile> -Verbose
    
  2. 升級完成後(視是否首次部署及資源群組大小,需時 15 到 45 分鐘),WAD 應該會收集效能計數器,並傳送到叢集相關儲存帳號中名為 WADPerformanceCountersTable 的表格。 透過將 AI Sink 加入 Resource Manager 範本,在 Application Insights 中查看效能計數器。

下一步