Application Insights 代理(以前称为状态监视器 v2)故障排除Troubleshooting Application Insights Agent (formerly named Status Monitor v2)

启用监视时,可能会遇到阻止数据收集的问题。When you enable monitoring, you might experience issues that prevent data collection. 本文列出了所有已知问题,并提供了故障排除示例。This article lists all known issues and provides troubleshooting examples. 如果遇到此处未列出的问题,可以通过 GitHub 联系我们。If you come across an issue that's not listed here, you can contact us on GitHub.

已知问题Known issues

应用的 bin 目录中存在冲突的 DllConflicting DLLs in an app's bin directory

如果 bin 目录中存在以上任何 DLL,则监视可能会失败:If any of these DLLs are present in the bin directory, monitoring might fail:

  • Microsoft.ApplicationInsights.dllMicrosoft.ApplicationInsights.dll
  • Microsoft.AspNet.TelemetryCorrelation.dllMicrosoft.AspNet.TelemetryCorrelation.dll
  • System.Diagnostics.DiagnosticSource.dllSystem.Diagnostics.DiagnosticSource.dll

其中某些 DLL 包含在 Visual Studio 的默认应用模板中,即使应用不使用它们也是如此。Some of these DLLs are included in the Visual Studio default app templates, even if your app doesn't use them. 可以使用故障排除工具来查看症状行为:You can use troubleshooting tools to see symptomatic behavior:

  • PerfView:PerfView:

    ThreadID="7,500" 
    ProcessorNumber="0" 
    msg="Found 'System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' assembly, skipping attaching redfield binaries" 
    ExtVer="2.8.13.5972" 
    SubscriptionId="" 
    AppName="" 
    FormattedMessage="Found 'System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' assembly, skipping attaching redfield binaries" 
    
  • IISReset 和应用负载(不含遥测数据)。IISReset and app load (without telemetry). 使用 Sysinternals(Handle.exe 和 ListDLLs.exe)进行调查:Investigate with Sysinternals (Handle.exe and ListDLLs.exe):

    .\handle64.exe -p w3wp | findstr /I "InstrumentationEngine AI. ApplicationInsights"
    E54: File  (R-D)   C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Runtime\Microsoft.ApplicationInsights.RedfieldIISModule.dll
    
    .\Listdlls64.exe w3wp | findstr /I "InstrumentationEngine AI ApplicationInsights"
    0x0000000009be0000  0x127000  C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation64\MicrosoftInstrumentationEngine_x64.dll
    0x0000000009b90000  0x4f000   C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation64\Microsoft.ApplicationInsights.ExtensionsHost_x64.dll
    0x0000000004d20000  0xb2000   C:\Program Files\WindowsPowerShell\Modules\Az.ApplicationMonitor\content\Instrumentation64\Microsoft.ApplicationInsights.Extensions.Base_x64.dll
    

与 IIS 共享配置冲突Conflict with IIS shared configuration

如果拥有 Web 服务器群集,则可能会使用共享配置If you have a cluster of web servers, you might be using a shared configuration. HttpModule 无法注入到此共享配置中。The HttpModule can't be injected into this shared configuration. 在每个 Web 服务器上运行 Enable 命令,以将 DLL 安装到每个服务器的 GAC 中。Run the Enable command on each web server to install the DLL into each server's GAC.

在运行 Enable 命令后,请完成以下步骤:After you run the Enable command, complete these steps:

  1. 转到共享配置目录,并找到 applicationHost.config 文件。Go to the shared configuration directory and find the applicationHost.config file.
  2. 将以下行添加到配置的模块部分中:Add this line to the modules section of your configuration:
    <modules>
        <!-- Registered global managed http module handler. The 'Microsoft.AppInsights.IIS.ManagedHttpModuleHelper.dll' must be installed in the GAC before this config is applied. -->
        <add name="ManagedHttpModuleHelper" type="Microsoft.AppInsights.IIS.ManagedHttpModuleHelper.ManagedHttpModuleHelper, Microsoft.AppInsights.IIS.ManagedHttpModuleHelper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler,runtimeVersionv4.0" />
    </modules>
    

IIS 嵌套应用程序IIS Nested Applications

在 1.0 版中,我们不在 IIS 中检测嵌套应用程序。We don't instrument nested applications in IIS in version 1.0. 我们正在此处跟踪此问题。We're tracking this issue here.

高级 SDK 配置不可用。Advanced SDK Configuration isn't available.

在 1.0 版中,SDK 配置不向最终用户公开。The SDK configuration isn't exposed to the end user in version 1.0. 我们正在此处跟踪此问题。We're tracking this issue here.

故障排除Troubleshooting

PowerShell 故障排除Troubleshooting PowerShell

确定哪些模块可用Determine which modules are available

可以使用 Get-Module -ListAvailable 命令来确定安装了哪些模块。You can use the Get-Module -ListAvailable command to determine which modules are installed.

将模块导入到当前会话中Import a module into the current session

如果模块尚未加载到 PowerShell 会话中,你可以使用 Import-Module <path to psd1> 命令手动加载该模块。If a module hasn't been loaded into a PowerShell session, you can manually load it by using the Import-Module <path to psd1> command.

Application Insights 代理模块故障排除Troubleshooting the Application Insights Agent module

列出 Application Insights 代理模块中可用的命令List the commands available in the Application Insights Agent module

运行 Get-Command -Module Az.ApplicationMonitor 命令来获取可用命令:Run the command Get-Command -Module Az.ApplicationMonitor to get the available commands:

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Disable-ApplicationInsightsMonitoring              0.4.0      Az.ApplicationMonitor
Cmdlet          Disable-InstrumentationEngine                      0.4.0      Az.ApplicationMonitor
Cmdlet          Enable-ApplicationInsightsMonitoring               0.4.0      Az.ApplicationMonitor
Cmdlet          Enable-InstrumentationEngine                       0.4.0      Az.ApplicationMonitor
Cmdlet          Get-ApplicationInsightsMonitoringConfig            0.4.0      Az.ApplicationMonitor
Cmdlet          Get-ApplicationInsightsMonitoringStatus            0.4.0      Az.ApplicationMonitor
Cmdlet          Set-ApplicationInsightsMonitoringConfig            0.4.0      Az.ApplicationMonitor
Cmdlet          Start-ApplicationInsightsMonitoringTrace           0.4.0      Az.ApplicationMonitor

确定 Application Insights 代理模块的当前版本Determine the current version of the Application Insights Agent module

运行 Get-ApplicationInsightsMonitoringStatus -PowerShellModule 命令来显示有关该模块的以下信息:Run the Get-ApplicationInsightsMonitoringStatus -PowerShellModule command to display the following information about the module:

  • PowerShell 模块版本PowerShell module version
  • Application Insights SDK 版本Application Insights SDK version
  • PowerShell 模块的文件路径File paths of the PowerShell module

有关如何使用此 cmdlet 的详细说明,请查看 API 参考Review the API reference for a detailed description of how to use this cmdlet.

对正在运行的进程进行故障排除Troubleshooting running processes

可以检查已检测的计算机上的进程,以确定是否加载了所有 DLL。You can inspect the processes on the instrumented computer to determine if all DLLs are loaded. 如果监视功能在正常工作,则至少有 12 个 DLL 应加载。If monitoring is working, at least 12 DLLs should be loaded.

使用 Get-ApplicationInsightsMonitoringStatus -InspectProcess 命令来检查 DLL。Use the Get-ApplicationInsightsMonitoringStatus -InspectProcess command to check the DLLs.

有关如何使用此 cmdlet 的详细说明,请查看 API 参考Review the API reference for a detailed description of how to use this cmdlet.

使用 PerfView 收集 ETW 日志Collect ETW logs by using PerfView

设置Setup

  1. GitHub 下载 PerfView.exe 和 PerfView64.exe。Download PerfView.exe and PerfView64.exe from GitHub.
  2. 启动 PerfView64.exe。Start PerfView64.exe.
  3. 展开“高级选项” 。Expand Advanced Options.
  4. 清除这些复选框:Clear these check boxes:
    • ZipZip
    • 合并Merge
    • .NET 符号集合.NET Symbol Collection
  5. 设置以下“其他提供程序” :61f6ca3b-4b5f-5602-fa60-759a2a2d1fbd,323adc25-e39b-5c87-8658-2c1af1a92dc5,925fa42b-9ef6-5fa7-10b8-56449d7a2040,f7d60e07-e910-5aca-bdd2-9de45b46c560,7c739bb9-7861-412e-ba50-bf30d95eae36,61f6ca3b-4b5f-5602-fa60-759a2a2d1fbd,323adc25-e39b-5c87-8658-2c1af1a92dc5,252e28f4-43f9-5771-197a-e8c7e750a984Set these Additional Providers: 61f6ca3b-4b5f-5602-fa60-759a2a2d1fbd,323adc25-e39b-5c87-8658-2c1af1a92dc5,925fa42b-9ef6-5fa7-10b8-56449d7a2040,f7d60e07-e910-5aca-bdd2-9de45b46c560,7c739bb9-7861-412e-ba50-bf30d95eae36,61f6ca3b-4b5f-5602-fa60-759a2a2d1fbd,323adc25-e39b-5c87-8658-2c1af1a92dc5,252e28f4-43f9-5771-197a-e8c7e750a984

收集日志Collecting logs

  1. 在具有管理员权限的命令控制台中,运行 iisreset /stop 命令以禁用 IIS 和所有 Web 应用。In a command console with Admin privileges, run the iisreset /stop command to turn off IIS and all web apps.
  2. 在 PerfView 中,选择“开始收集” 。In PerfView, select Start Collection.
  3. 在具有管理员权限的命令控制台中,运行 iisreset /start 命令以启动 IIS。In a command console with Admin privileges, run the iisreset /start command to start IIS.
  4. 尝试浏览到你的应用。Try to browse to your app.
  5. 在应用加载后,请返回到 PerfView,然后选择“停止收集” 。After your app is loaded, return to PerfView and select Stop Collection.

后续步骤Next steps

  • 请查看 API 参考,以了解你可能错过的参数。Review the API reference to learn about parameters you might have missed.
  • 如果遇到此处未列出的问题,可以通过 GitHub 联系我们。If you come across an issue that's not listed here, you can contact us on GitHub.