Application Insights无法跟踪SQL查询 [英] Application Insights not tracking sql queries

查看:99
本文介绍了Application Insights无法跟踪SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置自己的环境以使用Status Monitor将数据发送到App Insight,并且除sql查询外都可以正常工作.

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

我在具有Azure数据库的Azure VM上有一个环境,并且SQL查询一直跟踪良好,但是在我自己的VM中针对我自己的数据库无法正常工作.

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.

在该环境中记录的sql跟踪类似于:"mssql-IP |数据库名称",而不是查询内容.

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

在两个环境中测试的应用程序都是相同的,因此SO版本是相同的.

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

我尝试针对Azure数据库配置环境,但是仍然存在相同的问题.

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

我安装了.NET 4.6,仍然是同样的问题.

I installed .NET 4.6 and still the same problem.

推荐答案

新方法(Application Insights代理,以前的状态监控器v2)

注意:声明时,需要一个新的PowerShell窗口/会话.

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

  1. 安装先决条件.
  2. 打开一个新的提升的PowerShell会话.
  3. 安装代理模块.
  4. 仅启用检测引擎.打开一个新的提升的PowerShell会话并运行以下命令:

  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

  • 执行OLD METHOD的步骤2(如下).

  • Perform Step 2 for OLD METHOD (below).

    重新启动IIS:

    iisreset
    

  • 查看更多说明

    旧方法(状态监控器v1)

    在回顾了所有有关该问题的文档,GitHub问题和博客文章之后,我相信对于IIS环境,我有明确的答案:

    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. 状态监视器来收集依赖性详细信息.这将配置必要的.NET分析器.即使您在构建时配置了Application Insights(即没有在运行时为状态监视器配置Application Insights)并且使用的是.NET 4.6+,状态监视器仍然需要存在. (我认为,Microsoft文档对此没有明确说明.)

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

    正确的权限:

    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
    

    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'
    

  • 更正IIS服务环境变量:

  • 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
    

  • 重新启动IIS:

  • Restart IIS:

    iisreset
    

  • 这篇关于Application Insights无法跟踪SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆