【问题标题】:Why am I seeing a large spike in Data ingestion from performance counter data?为什么我看到从性能计数器数据中提取的数据出现大幅飙升?
【发布时间】:2019-09-11 02:16:20
【问题描述】:

通过查看我的 Application Insights 成本管理报告,我注意到与性能计数器相关的数据摄取量激增。

Link to larger image

但是,我没有看到在同一时期的请求数量激增有任何显着相关性。

Link to larger image

我可以做些什么来了解这个问题的根本原因?

其他信息

经过一些调试,我能够找到这个问题的根源。

使用量在 9 月 7 日和 9 月 8 日达到峰值,然后在 9 日和 10 日逐渐减少。

我在 9 月 6 日所做的更改是将 Microsoft.ApplicationInsights.AspNetCore 从版本 2.6.1 升级到版本 2.7.1。 2.7.1 版已内置 ILogger 集成。

所以,我认为发生的事情是,在部署升级版 Microsoft.ApplicationInsights.AspNetCore 后,我可能将日志记录详细程度调高到无法显示性能计数器遥测数据,并在几天后更改了它当我注意到它时。

我希望这对可能遇到此问题的其他人有所帮助!

【问题讨论】:

    标签: azure-application-insights cost-management


    【解决方案1】:

    现在有一种更简洁的方法来实现禁用 PerformanceCounterModule(以及导致过多/不需要日志记录的其他模块);

    services.AddApplicationInsightsTelemetry(options =>
    {
        options.EnablePerformanceCounterCollectionModule = false;
        options.InstrumentationKey = configuration["ApplicationInsights:InstrumentationKey"];
    });
    

    【讨论】:

      【解决方案2】:

      Application Insights 2.7.1 已默认启用ILogger 捕获,但它只捕获Warning 或以上的日志消息。因此,除非您的应用程序正在生成大量警告或更高级别的 Ilogger 日志,否则这不会导致使用量激增。 如果报告的日志过多,可以更改此行为以进一步过滤日志。 https://docs.microsoft.com/en-us/azure/azure-monitor/app/ilogger#control-logging-level 从您分享的第一个屏幕截图来看,性能计数器似乎是唯一出现尖峰的类型 - ilogger 集成无法解释此尖峰,因为它只报告日志。

      更合乎逻辑的解释是 PerformanceCounter 模块本身,它在 2.7.1 之前的版本中不受支持。您可以使用 startup.cs 中的 ConfigureServices() 方法中的以下片段删除性能计数器集合

      使用 Microsoft.ApplicationInsights.DependencyCollector; 使用 Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector;

      public void ConfigureServices(IServiceCollection services)
      {
          services.AddApplicationInsightsTelemetry();
      
          // The following removes PerformanceCollectorModule to disable perf-counter collection.
          var performanceCounterService = services.FirstOrDefault<ServiceDescriptor>(t => t.ImplementationType == typeof(PerformanceCollectorModule));
          if (performanceCounterService != null)
          {
           services.Remove(performanceCounterService);
          }
      }
      

      【讨论】:

      • 谢谢@cijothomas,你说的很有道理。每个升级到 2.7.1 的人肯定都会遇到这个问题吗?有没有可以用来控制性能计数器模块的配置设置?
      • 我上面的回复显示了如何删除 performancecountermodule。
      • 我不知道您是如何看到性能计数器的数据量激增的,除非您有大量服务器。因为性能计数器每分钟只发送一次计数器,这通常是非常小的总容量。但是 perfcounters 是从每个实例中发出的,所以如果实例的数量很大,它可以每分钟都发出计数器。
      • 感谢@cijothomas 的帮助。在我的例子中,性能计数器数据来自单个、低容量的 Azure AppService。似乎很奇怪。我可能会在 GitHub 上将其作为问题提及。
      猜你喜欢
      • 2021-02-01
      • 1970-01-01
      • 2013-01-18
      • 2011-02-06
      • 1970-01-01
      • 1970-01-01
      • 2017-12-09
      • 2015-10-17
      • 1970-01-01
      相关资源
      最近更新 更多