Felsöka Azure Application Insights-agenten (tidigare Status Monitor v2)

Den här artikeln innehåller felsökningsinformation som hjälper dig att lösa problem med datainsamling som kan uppstå när Application Insights-övervakning är aktiverat.

Kända problem

Motstridiga DLL:er i en apps bin-katalog

Om något av dessa dynamiska länkbibliotek (DLL: er) finns i bin-katalogen kan övervakningen misslyckas:

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

Några av dessa DLL:er ingår i Visual Studio-standardappmallarna, även om din app inte använder dem. Du kan använda felsökningsverktyg, till exempel följande verktyg, för att se symptomatiskt beteende:

  • 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 och appinläsning (utan telemetri). Undersök med Sysinternals (Handle.exe och 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
    

PowerShell-versioner

Den här produkten har skrivits och testats med PowerShell version 5.1. Den här modulen är inte kompatibel med PowerShell-version 6 eller 7. Vi rekommenderar att du använder PowerShell 5.1 tillsammans med nyare versioner. Mer information finns i Använda PowerShell 7 sida vid sida med PowerShell 5.1.

Konflikt med delad IIS-konfiguration

Om du har ett kluster med webbservrar kanske du använder en delad konfiguration. Det går inte att mata in HttpModule i den här delade konfigurationen. Kör kommandot Aktivera på varje webbserver för att installera DLL:en i varje servers globala sammansättningscache (GAC).

När du har kört kommandot Aktivera utför du följande steg:

  1. Gå till den delade konfigurationskatalogen och leta upp applicationHost.config-filen .

  2. Lägg till den här XML-koden i modulavsnittet<> i konfigurationen:

    <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>
    

Kapslade IIS-program

Vi instrumenterade inte kapslade program i Internet Information Services (IIS) i version 1.0.

Avancerad SDK-konfiguration är inte tillgänglig

SDK-konfigurationen exponeras inte för slutanvändaren i version 1.0.

Felsöka PowerShell

Avgöra vilka moduler som är tillgängliga

Du kan använda Get-Module -ListAvailable kommandot för att avgöra vilka moduler som är installerade.

Importera en modul till den aktuella sessionen

Om en modul inte har lästs in i en PowerShell-session kan du läsa in den manuellt genom att Import-Module <path to psd1> köra kommandot .

Felsöka Application Insights Agent-modulen

Lista de kommandon som är tillgängliga i Application Insights Agent-modulen

Get-Command -Module Az.ApplicationMonitor Kör kommandot för att hämta de tillgängliga kommandona:

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

Fastställa den aktuella versionen av Application Insights Agent-modulen

Get-ApplicationInsightsMonitoringStatus -PowerShellModule Kör kommandot för att visa följande information om modulen:

  • PowerShell-modulversion
  • Application Insights SDK-version
  • Filsökvägar för PowerShell-modulen

Läs referensen för Get-ApplicationInsightsMonitoringStatus för en detaljerad beskrivning av hur du använder den här cmdleten.

Felsöka processer som körs

Du kan granska processerna på den instrumenterade datorn för att avgöra om alla DLL:er läses in och miljövariabler har angetts. Om övervakningen fungerar bör minst 12 DLL:er läsas in.

  • Get-ApplicationInsightsMonitoringStatus -InspectProcess Använd kommandot för att kontrollera DLL:er.
  • (Get-Process -id <process-identifier>).StartInfo.EnvironmentVariables Använd kommandot för att kontrollera miljövariablerna. Följande miljövariabler anges i arbetsprocessen eller .NET Core-processen:
COR_ENABLE_PROFILING=1
COR_PROFILER={324F817A-7420-4E6D-B3C1-143FBED6D855}
COR_PROFILER_PATH_32=<path-to-MicrosoftInstrumentationEngine_x86.dll>
COR_PROFILER_PATH_64=<path-to-MicrosoftInstrumentationEngine_x64.dll>
MicrosoftInstrumentationEngine_Host={CA487940-57D2-10BF-11B2-A3AD5A13CBC0}
MicrosoftInstrumentationEngine_HostPath_32=<path-to-Microsoft.ApplicationInsights.ExtensionsHost_x86.dll>
MicrosoftInstrumentationEngine_HostPath_64=<path-to-Microsoft.ApplicationInsights.ExtensionsHost_x64.dll>
MicrosoftInstrumentationEngine_ConfigPath32_Private=<path-to-Microsoft.InstrumentationEngine.Extensions.config>
MicrosoftInstrumentationEngine_ConfigPath64_Private=<path-to-Microsoft.InstrumentationEngine.Extensions.config>
MicrosoftAppInsights_ManagedHttpModulePath=<path-to-Microsoft.ApplicationInsights.RedfieldIISModule.dll>
MicrosoftAppInsights_ManagedHttpModuleType=Microsoft.ApplicationInsights.RedfieldIISModule.RedfieldIISModule
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=Microsoft.ApplicationInsights.StartupBootstrapper
DOTNET_STARTUP_HOOKS=<path-to-Microsoft.ApplicationInsights.StartupHook.dll>

Läs referensen för Get-ApplicationInsightsMonitoringStatus för en detaljerad beskrivning av hur du använder den här cmdleten.

Samla in ETW-loggar med hjälp av PerfView

Konfiguration

  1. Ladda ned PerfView.exe från GitHub.

  2. Kör PerfView.exe.

  3. På menyraden väljer du Samla in>.

  4. Expandera Avancerade alternativ.

  5. Avmarkera dessa kryssrutor:

    • Zip
    • Sammanfoga
    • .NET-symbolsamling
  6. Ange följande ytterligare providers:

    *Microsoft-ApplicationInsights-AspNetCore,*Microsoft-ApplicationInsights-AspNetCore-AiHostingStartup,*Microsoft-ApplicationInsights-AspNetCore-StartupBootstrapper,*Microsoft-ApplicationInsights-AspNetCore-StartupHook,*Microsoft-ApplicationInsights-Core,*Microsoft-ApplicationInsights-Data,*Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Dependency,*Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Web,*Microsoft-ApplicationInsights-Extensibility-DependencyCollector,*Microsoft-ApplicationInsights-Extensibility-EventCounterCollector,*Microsoft-ApplicationInsights-Extensibility-EventSourceListener,*Microsoft-ApplicationInsights-Extensibility-HostingStartup,*Microsoft-ApplicationInsights-Extensibility-PerformanceCollector,*Microsoft-ApplicationInsights-Extensibility-PerformanceCollector-QuickPulse,*Microsoft-ApplicationInsights-Extensibility-Web,*Microsoft-ApplicationInsights-Extensibility-WindowsServer,*Microsoft-ApplicationInsights-FrameworkLightup,*Microsoft-ApplicationInsights-IIS-ManagedHttpModuleHelper,*Microsoft-ApplicationInsights-Java-IPA,*Microsoft-ApplicationInsights-LoggerProvider,*Microsoft-ApplicationInsights-Nodejs-IPA,*Microsoft-ApplicationInsights-RedfieldIISModule,*Microsoft-ApplicationInsights-SnapshotCollectorLightup,*Microsoft-ApplicationInsights-WindowsServer-Core,*Microsoft-ApplicationInsights-WindowsServer-TelemetryChannel,*Redfield-Microsoft-ApplicationInsights-AspNetCore,*Redfield-Microsoft-ApplicationInsights-Core,*Redfield-Microsoft-ApplicationInsights-Data,*Redfield-Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Dependency,*Redfield-Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Web,*Redfield-Microsoft-ApplicationInsights-Extensibility-DependencyCollector,*Redfield-Microsoft-ApplicationInsights-Extensibility-EventCounterCollector,*Redfield-Microsoft-ApplicationInsights-Extensibility-EventSourceListener,*Redfield-Microsoft-ApplicationInsights-Extensibility-PerformanceCollector,*Redfield-Microsoft-ApplicationInsights-Extensibility-PerformanceCollector-QuickPulse,*Redfield-Microsoft-ApplicationInsights-Extensibility-Web,*Redfield-Microsoft-ApplicationInsights-Extensibility-WindowsServer,*Redfield-Microsoft-ApplicationInsights-LoggerProvider,*Redfield-Microsoft-ApplicationInsights-WindowsServer-TelemetryChannel

Samla in loggar

  1. I en kommandokonsol med administratörsbehörighet kör iisreset /stop du kommandot för att inaktivera IIS och alla webbappar.

  2. I PerfView väljer du Starta samling.

  3. I en kommandokonsol med administratörsbehörighet kör iisreset /start du kommandot för att starta IIS.

  4. Försök att bläddra till din app.

  5. När appen har lästs in går du tillbaka till PerfView och väljer Stoppa samling.

Nästa steg

  • Granska API-referensen för att lära dig mer om parametrar som du kanske har missat.

Kontakta oss för att få hjälp

Om du har frågor eller behöver hjälp skapar du en supportförfrågan eller frågar Azure community support. Du kan också skicka produktfeedback till Azure-feedbackcommunityn.