如何将 Disk Free Space 性能计数器添加到 Azure Application Insights?

How to add Disk Free Space performance counter to Azure Application Insights?

我知道 Azure Application Insights 可以使用 ApplicationInsights.config 中的语法收集额外的性能计数器:

  <Counters>
    <Add PerformanceCounter="\Process(??APP_WIN32_PROC??)\Handle Count" ReportAs="Process handle count" />
    ...
  </Counters>

  PerformanceCounter must be either \CategoryName(InstanceName)\CounterName or \CategoryName\CounterName

  -->
</Add>

如何将 "Free Disk Space" 和 "Free Disk Space %" 性能计数器实际添加到此文件?

另外,旁注,我希望 Application Insights 已经收集了这个,有点令人惊讶的是我们必须竭尽全力添加它。

非常感谢任何帮助!

请在ApplicationInsights.config中尝试以下设置:

 <Counters>
        <Add PerformanceCounter="\LogicalDisk(_total)\% Free Space" ReportAs="the space perc"/>
        <Add PerformanceCounter="\LogicalDisk(_total)\Free Megabytes" ReportAs="the space left"/>
 </Counters>

只是为了补充 Ivan Yang 的回答,也可以用代码完成:

var perfCollectorModule = new PerformanceCollectorModule();
perfCollectorModule.Counters.Add(new PerformanceCounterCollectionRequest(@"\Sales(photo)\# Items Sold", "Photo sales"));
perfCollectorModule.Initialize(TelemetryConfiguration.Active);

System performance counters in Application Insights