【问题标题】:Azure. ApplicationInsights. Inexplicable error messge in AI log天蓝色。应用洞察。 A日志中出现莫名其妙的错误信息
【发布时间】:2017-07-21 20:48:26
【问题描述】:

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

AI:收集 6 个已配置的性能计数器时出错。请 检查配置。计数器\ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec: 未能执行 首先读取性能计数器。请确保它存在。 类别:ASP.NET 应用程序,计数器:Requests/Sec,实例 SFAIUsingSrv.exe
Counter .NET CLR Exceptions(??APP_CLR_PROC??)# of Exceps Throw / sec: 未能执行第一次读取以提高性能 柜台。请确保它存在。类别:.NET CLR 异常, 计数器:# of Exceps Thrown / sec,实例
计数器 \ASP.NET Applications(??APP_W3SVC_PROC??)\Request Execution Time: 未能执行性能计数器的第一次读取。请确保它 存在。类别:ASP.NET 应用程序,计数器:请求执行 时间,实例 SFAIUsingSrv.exe
.Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Requests In Application Queue: 失败 执行性能计数器的第一次读取。请确保它 存在。类别:ASP.NET 应用程序,计数器:Requests In 应用程序队列,实例 SFAIUsingSrv.exe
Counter \Process(??APP_W3SVC_PROC??)\Handle Count: 未能执行第一个 读取性能计数器。请确保它存在。类别: 进程、计数器:Handle Count、实例 SFAIUsingSrv.exe
计数器 \ASP.NET 应用程序(??APP_W3SVC_PROC??)\Requests/Sec: 失败 执行性能计数器的第一次读取。请确保它 存在。类别:ASP.NET 应用程序,计数器:Requests/Sec, 实例 SFAIUsingSrv.exe

这是我的 Service Fabric 服务的 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>

谁能帮我理解为什么我会收到这些消息?

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

EDIT2: 这些消息仅在服务启动时显示。

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

【问题讨论】:

  • 看起来它正在尝试跟踪来自 w3Svc 的指标,这通常是负责在 IIS 上代理 Web 流量的可执行文件/进程。如果您实施的服务不使用该流程,人工智能将在跟踪这些指标时遇到麻烦。我的猜测是 Windows Service 和 Service Fabric 可能不会公开该过程。忽略它可能是安全的......编辑:您可以在它正在寻找的配置中看到“APP_W3SVC_PROC”。
  • @Porschiey 好吧,产生这些消息的是服务,而不是网络应用程序。我已经一起删除了 counters 集合来解决这个问题。

标签: azure azure-application-insights azure-performancecounters


【解决方案1】:

如果它是 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 将停止尝试完全收集性能计数器。

【讨论】:

  • 感谢您的洞察力!我能够摆脱消息,但我仍然很困惑为什么我首先看到它们?尤其是那些与网络应用相关的,当没有任何网络应用被使用时......
  • 您的项目显然配置为使用 Web 版本的应用程序洞察力,因此它假定正在使用一个 Web 应用程序,因此它会尝试收集您想要的东西。
  • 哦...我明白了。在创建 AI 资源时,其类型已设置为 ASP.NET。可能应该将其设置为“常规”以更好地反映其使用的实际情况。
  • 门户中显示的类型实际上只是改变了门户本身的一些行为,即概览刀片中显示的内容类型。发送的内容完全取决于您在本地使用的 sdk 和配置。 (您可以创建一个“通用”应用程序并使用 web sdk 发送数据,您可以创建类型为“python”并从节点向其发送数据等)许多应用程序有许多不同的东西将数据发送到同一资源(例如web 和 javascript 和节点都去同一个地方)
  • 嗯,问题不在于我们发送给 AI 的内容,而是 AI 默认发送的内容。如果您查看我提供的 ApplicinInsight.config 没有任何内容,即“需要收集 Web 应用遥测”(至少对我而言),这就是为什么我一直在努力理解为什么我遇到“out开箱即用的性能计数器。
猜你喜欢
  • 2012-03-12
  • 1970-01-01
  • 2019-02-04
  • 1970-01-01
  • 2021-11-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多