6

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 with Azure Database and the SQL queries are been tracking well, but in my own VM against my own Databases not working.

The sql trace recorded on that environment is like that: "mssql-IP | database-name" instead of query content.

The application tested in both environment is the same, the SO version is the same.

I tryed configure my environment against Azure Databases, but still the same problem.

I installed .NET 4.6 and still the same problem.

1
  • 1
    Can confirm; I have a Server 2012 R2 hosted web app that is .NET 4.6.1 with AppInsights 2.1 installed (app pool is running with domain service account) and I am not getting SQL dependency detail data either. I have seen it work on other apps on other servers, but we have too many permutations to nail anything down (8 different web servers with 5-8 web apps on each, in various versions of .NET and various versions of App Insights SDK)
    – BrettJ
    Sep 9, 2016 at 18:01

3 Answers 3

8

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
    
4

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.

4
  • 1
    Hi, I execute that query on Analytics and y get that version: r_rddf: 2.1.0.363 I dont't know how can I check the installation of Status Monitor, I only executed the installer and then the Status Monitor downloaded latests binaries from internet.
    – Drazul
    Sep 15, 2016 at 10:05
  • @Drazul Just as a basic check does your IIS app show up in Status Monitor if you open it? If so, is the app enabled? There's a guide here that shows some screenshots about how apps should appear after being enabled, as well as troubleshooting steps for missing telemetry Sep 16, 2016 at 17:42
  • I deployed same version of my apps on Azure, with Azure DB, and App Insight works fine, and App Insight was installed with same binary files The only difference that can i see is the configuration of Windows Server on Azure, but i check all installed features and are the same.
    – Drazul
    Sep 21, 2016 at 8:35
  • Any idea why we'd get dependency tracking of SQL commands hitting one SQL Server, but not see commands hitting a different SQL server from the same instance of an application?
    – Dude0001
    Dec 5, 2016 at 1:01
4

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
2
  • Awesome finding Drazul, how could you find that? Sep 1, 2021 at 14:16
  • 1
    @WildanMuhlis to be honest I don't remember, but I should have been documented ithere also
    – Drazul
    Sep 2, 2021 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.