Dra*_*zul 6 sql-server azure-application-insights
我正在尝试配置我自己的环境,以使用Status Monitor将数据发送到App Insight,并且除sql查询外都能正常工作。
我在具有Azure数据库的Azure VM上有一个环境,并且SQL查询一直跟踪良好,但是在我自己的VM中针对我自己的数据库无法正常工作。
在该环境上记录的sql跟踪类似于:“ mssql-IP |数据库名称”,而不是查询内容。
在两个环境中测试的应用程序是相同的,SO版本是相同的。
我尝试针对Azure数据库配置环境,但是仍然存在相同的问题。
我安装了.NET 4.6,仍然是同样的问题。
NEW METHOD (Application Insights Agent, Formerly Status Monitor v2)
Note: A new PowerShell window/session is required when stated.
Enable just the instrumentation engine. Open a new elevated PowerShell session and run the following:
Enable-InstrumentationEngine
Run Code Online (Sandbox Code Playgroud)Restart IIS:
iisreset
Run Code Online (Sandbox Code Playgroud)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:
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.)
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
Run Code Online (Sandbox Code Playgroud)
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'
Run Code Online (Sandbox Code Playgroud)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
Run Code Online (Sandbox Code Playgroud)Restart IIS:
iisreset
Run Code Online (Sandbox Code Playgroud)您应该验证状态监视器收集的数据是否正在进入 Application Insights。
在Analytics中尝试查询:
dependencies | where timestamp > ago(1d) | summarize count() by cloud_RoleInstance, sdkVersion
Run Code Online (Sandbox Code Playgroud)
如果您看到 sdkVersion 结果以 rddf 而不是 rddp 为前缀,则 SDK 正在发送没有状态监视器增强功能的数据(如 SQL 查询内容)。如果是这种情况,请检查状态监视器的安装,以确保它对于您的应用程序处于活动状态。