本文档介绍通过 Windows 群集的 Windows Azure 诊断(WAD)扩展设置性能计数器收集所需的步骤。 对于 Linux 群集,请设置 Log Analytics 代理 以收集节点的性能计数器。
注释
您应在群集上部署 WAD 扩展,以便这些步骤能够正常执行。 如果未设置,请访问 使用 Windows Azure 诊断进行事件聚合和收集。
注释
建议使用 Azure Az PowerShell 模块与 Azure 交互。 请参阅安装 Azure PowerShell 以开始使用。 若要了解如何迁移到 Az PowerShell 模块,请参阅 将 Azure PowerShell 从 AzureRM 迁移到 Az。
通过 WadCfg 收集性能计数器
若要通过 WAD 收集性能计数器,需要在群集的资源管理器模板中适当修改配置。 按照以下步骤,将您想要收集的性能计数器添加到您的模板中,并运行 Resource Manager 资源升级。
在群集模板中查找 WAD 配置 - 查找
WadCfg。 你将添加性能计数器用于在DiagnosticMonitorConfiguration收集。通过将以下部分添加到你的
DiagnosticMonitorConfiguration中来设置配置,以收集性能计数器。"PerformanceCounters": { "scheduledTransferPeriod": "PT1M", "PerformanceCounterConfiguration": [] }定义
scheduledTransferPeriod的作用是确定收集的计数器值被传输到 Azure 存储表和任何配置的目标的频率。将要收集的性能计数器添加到上一步声明的
PerformanceCounterConfiguration中。 要收集的每个计数器都用counterSpecifier、sampleRate、unit、annotation和任何相关的sinks定义。
下面是一个配置示例,包括 总处理器时间 计数器(CPU 用于处理操作的时间量)和 每秒 Service Fabric Actor 方法调用次数,这是 Service Fabric 自定义性能计数器之一。 有关 Service Fabric 自定义性能计数器的完整列表,请参阅 Reliable Actor 性能计数器 和 Reliable Service 性能计数器 。
"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'))]"
},
....
添加需要收集的相应性能计数器后,需要升级群集资源,以便这些更改反映在正在运行的群集中。 保存修改过的
template.json并打开 PowerShell。 您可以使用New-AzResourceGroupDeployment升级您的集群。 调用需要资源组的名称、更新的模板文件和参数文件,并提示资源管理器对更新的资源进行适当的更改。 登录到帐户并位于正确的订阅中后,请使用以下命令运行升级:New-AzResourceGroupDeployment -ResourceGroupName <ResourceGroup> -TemplateFile <PathToTemplateFile> -TemplateParameterFile <PathToParametersFile> -Verbose升级完成后(需要 15-45 分钟,具体取决于它是第一个部署和资源组的大小),WAD 应收集性能计数器并将其发送到与群集关联的存储帐户中名为 WADPerformanceCountersTable 的表。 通过将 AI Sink 添加到资源管理器模板,查看 Application Insights 中的性能计数器。
后续步骤
- 为群集收集更多性能计数器。 请参阅性能指标,以获取应收集的计数器列表。
-
使用监控和诊断功能,结合 Windows VM 和 Azure 资源管理器模板,对你的
WadCfg进行进一步修改,包括配置更多存储帐户以接收诊断数据。 - 访问 WadCfg 生成器 ,从头开始生成模板,并确保语法正确。(https://azure.github.io/azure-diagnostics-tools/config-builder/) 从头开始生成模板,并确保语法正确。