天蓝色。应用洞察。 A日志中莫名其妙的错误信息

Azure. ApplicationInsights. Inexplicable error messge in AI log

我在 Azure 门户中设置了 AppllicationInsights 资源。有 2 个服务写入其中:windows 本地服务和本地服务结构集群上的服务结构服务 运行。我在两个服务中都使用 TelemetryClient 对象将数据发送到 Azure ApplicationInsights 资源。看起来我收到了我想要的所有消息,但有些消息来源我不明白。这是奇怪消息的示例:

AI: Error collecting 6 of the configured performance counters. Please check the configuration. Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Requests/Sec, instance SFAIUsingSrv.exe
Counter .NET CLR Exceptions(??APP_CLR_PROC??)# of Exceps Thrown / sec: Failed to perform the first read for performance counter. Please make sure it exists. Category: .NET CLR Exceptions, counter: # of Exceps Thrown / sec, instance
Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Request Execution Time: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Request Execution Time, instance SFAIUsingSrv.exe
.Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Requests In Application Queue: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Requests In Application Queue, instance SFAIUsingSrv.exe
Counter \Process(??APP_W3SVC_PROC??)\Handle Count: Failed to perform the first read for performance counter. Please make sure it exists. Category: Process, counter: Handle Count, instance SFAIUsingSrv.exe
Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Requests/Sec, instance SFAIUsingSrv.exe

这是我的 ApplicationInsights.config 服务结构服务:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
  <InstrumentationKey>some instrumentation key</InstrumentationKey>
  <TelemetryInitializers>
        <Add Type="Microsoft.ApplicationInsights.DependencyCollector.HttpDependenciesParsingTelemetryInitializer, Microsoft.AI.DependencyCollector"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureWebAppRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.AI.WindowsServer"/>
    </TelemetryInitializers>
    <TelemetryModules>
        <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
            <ExcludeComponentCorrelationHttpHeadersOnDomains>
                <!-- 
        Requests to the following hostnames will not be modified by adding correlation headers. 
        This is only applicable if Profiler is installed via either StatusMonitor or Azure Extension.
        Add entries here to exclude additional hostnames.
        NOTE: this configuration will be lost upon NuGet upgrade.
        -->
                <Add>core.windows.net</Add>
                <Add>core.chinacloudapi.cn</Add>
                <Add>core.cloudapi.de</Add>
                <Add>core.usgovcloudapi.net</Add>
                <Add>localhost</Add>
                <Add>127.0.0.1</Add>
            </ExcludeComponentCorrelationHttpHeadersOnDomains>
        </Add>
        <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
     <!--      
      The following placeholders are supported as InstanceName:
        ??APP_WIN32_PROC?? - instance name of the application process  for Win32 counters.
        ??APP_W3SVC_PROC?? - instance name of the application IIS worker   process for IIS/ASP.NET counters.
        ??APP_CLR_PROC?? - instance name of the application CLR process for .NET counters.
-->
        </Add>
        <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer">
            <!--</Add>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.FirstChanceExceptionStatisticsTelemetryModule, Microsoft.AI.WindowsServer">
-->
        </Add>
    </TelemetryModules>
    <TelemetryProcessors>
        <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector"/>
        <Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
            <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
            <ExcludedTypes>Event</ExcludedTypes>
        </Add>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
            <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
            <IncludedTypes>Event</IncludedTypes>
        </Add>
    </TelemetryProcessors>
    <TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/>
<!-- 
    Learn more about Application Insights configuration with ApplicationInsights.config here: 
    http://go.microsoft.com/fwlink/?LinkID=513840

    Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
  -->
</ApplicationInsights>

Could anybody help me understand why I am getting those messages?

编辑: 一直在生成这些消息的是我的服务(windows 服务和服务结构服务)。这两项服务都已 运行 在我的开发箱中。因此,当没有任何网络应用程序被使用时,看到这些与网络应用程序相关的消息是非常混乱的。但是后来我注释掉了 ApplicationInsights.config 文件中的 PerformanceCounterCollector 部分不再生成消息,如果我能找到一种方法以更友好的方式处理这些消息,我会更新我的问题。

编辑2: 这些消息仅在服务启动时显示。

EDIT3: 以下是为服务结构服务安装的所有块包:

如果它是一个 Azure Web 应用程序,只有一部分性能计数器会被 Azure 公开,它们有些 记录在此处:

https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/develop/Src/PerformanceCollector/Shared/Implementation/WebAppPerformanceCollector/CounterFactory.cs

如果您正在控制服务器,则需要确保任何用户 运行 IIS 网站/应用程序池都是 Performance Monitor Users 组的成员,以便它可以读取性能计数器。

这些消息来自 PerfCounterCollector 包的默认配置,它包含在 WindowsServer 包中,您可以在 github source for the perf counter collector

此处查看

如果您根本不使用性能收集器的东西,只是希望它全部消失,您可以删除整个

<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
...stuff about perf counters here...
</Add>

部分和 Application Insights 将停止尝试完全收集性能计数器。