Application Insights not tracking sql queries

后端 未结 3 1417
无人及你
无人及你 2020-12-15 01:36

I\'m trying to configure my own environment to send data to App Insight with Status Monitor and works fine except sql queries.

I have one environment on Azure VM wit

相关标签:
3条回答
  • 2020-12-15 01:54

    You should verify Status Monitor-collected data is making its way to Application Insights.

    In Analytics try the query:

    dependencies | where timestamp > ago(1d) | summarize count() by cloud_RoleInstance, sdkVersion
    

    If you see sdkVersion results prefixed with rddf instead of rddp, the SDK is sending data without the enhancements from Status Monitor (like SQL query content). If this is the case, check your installation of Status Monitor to ensure it's active for your application.

    0 讨论(0)
  • 2020-12-15 01:57

    NEW METHOD (Application Insights Agent, Formerly Status Monitor v2)

    Note: A new PowerShell window/session is required when stated.

    1. Install prerequisites in an elevated PowerShell session.
    2. Open a new elevated PowerShell session.
    3. Install the agent module.
    4. Enable just the instrumentation engine. Open a new elevated PowerShell session and run the following:

      Enable-InstrumentationEngine
      
    5. Perform Step 2 for OLD METHOD (below).

    6. Restart IIS:

      iisreset
      

    See more instructions.


    OLD METHOD (Status Monitor v1)

    After reviewing every scrap of documentation, GitHub issue, and blog post I could find on this problem, I believe I have the definitive answer for an IIS environment:

    1. Status Monitor needs to be installed to collect dependency details. This configures the necessary .NET profiler. Even if you have Application Insights configured at build time (i.e. not having Status Monitor configure Application Insights for you at runtime) and are using .NET 4.6+, Status Monitor still needs to be present. (In my opinion, the Microsoft documentation does not make this clear.)

    2. Correct permissions:

      CMD

      icacls %WINDIR%\Temp /t /c /grant IIS_IUSRS:(OI)(CI)M
      icacls %WINDIR%\System32\config\systemprofile\AppData\Local /t /c /grant IIS_IUSRS:(OI)(CI)M
      

      or

      PowerShell

      icacls $env:WINDIR\Temp /t /c /grant IIS_IUSRS:'(OI)(CI)M'
      icacls $env:WINDIR\System32\config\systemprofile\AppData\Local /t /c /grant IIS_IUSRS:'(OI)(CI)M'
      
    3. Correct IIS service environment variables:

      Get-Item 'HKLM:\SYSTEM\CurrentControlSet\Services\W3SVC' | Remove-ItemProperty -Name Environment -ErrorAction SilentlyContinue
      Get-Item 'HKLM:\SYSTEM\CurrentControlSet\Services\W3SVC' | New-ItemProperty -Name Environment -Value "COR_ENABLE_PROFILING=1","COR_PROFILER={324F817A-7420-4E6D-B3C1-143FBED6D855}","MicrosoftInstrumentationEngine_Host={CA487940-57D2-10BF-11B2-A3AD5A13CBC0}" -PropertyType MultiString
      
    4. Restart IIS:

      iisreset
      
    0 讨论(0)
  • 2020-12-15 02:02

    I finally solved this problem.

    I grant modify access to IIS_IUSRS group for these paths:

    • %WINDIR%\Temp
    • %WINDIR%\System32\config\systemprofile\AppData\Local

    Then, Application Insights started to record SQL queries.

    You also can do this via the command line:

    • icacls %WINDIR%\Temp /t /c /grant IIS_IUSRS:(OI)(CI)M
    • icacls %WINDIR%\System32\config\systemprofile\AppData\Local /t /c /grant IIS_IUSRS:(OI)(CI)M
    0 讨论(0)
提交回复
热议问题