Azure Application Insights 不显示数据

Ras*_*nov 9 asp.net azure azure-application-insights .net-core

我有一个作为 Azure 应用服务运行的 ASP.NET Core 应用程序。Azure Application Insights 已启用(我按照这些说明进行操作)。问题是我的 Azure 门户上的 Azure Insights 实例除了实时指标之外没有显示任何有用的数据(请参见屏幕截图)。正如您所看到的,屏幕截图上有多个请求和自定义事件。

但是,当我打开交易搜索时,它什么也没有显示(参见屏幕截图)。活动页面也是空的(参见屏幕截图)。

到目前为止,我仔细检查了 InstrumentKey。我还尝试使用 ConnectionString 而不是 InstrumentKey,但没有帮助。

我的应用程序在 .NET Core 3.1 上运行。我安装了最新版本的 Microsoft.ApplicationInsights.AspNetCore 包,即 2.19.0。

以下是在 Program.cs 中配置日志记录的方式:

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .ConfigureLogging(builder =>
            {
                builder.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Information);
            });
Run Code Online (Sandbox Code Playgroud)

下面是 Startup.cs 中的代码:

services.AddApplicationInsightsTelemetry(new ApplicationInsightsServiceOptions 
        {
            ConnectionString = Environment.GetEnvironmentVariable("APPLICATIONINSIGHTS_CONNECTION_STRING")
        });
Run Code Online (Sandbox Code Playgroud)

LogLevel 也在 appsettings.json 中配置:

"Logging": {
"LogLevel": {
  "Default": "Warning"
},
"ApplicationInsights": {
  "LogLevel": {
    "Default": "Information"
  }
}
Run Code Online (Sandbox Code Playgroud)

更新:我的管理员拥有更多权限,可以查看所有数据,包括事件、性能操作等。所以我想这与权限有关。尽管奇怪的是我没有看到任何警告消息。管理员给我分配了更多角色(参见屏幕截图),但这没有任何区别。

对于这个问题的任何帮助,我将不胜感激!

Ras*_*nov 10

在把我头上几乎所有的头发都扯下来后,我终于解决了这个问题!事实证明,Azure Application Insights 的实例已链接到属于我无权访问的资源组的日志分析工作区。因此日志已正确存储,但我无权读取它们。我的管理员通过创建一个新的 Azure Application Insights 实例解决了这个问题,该实例链接到我的资源组中的日志分析工作区。对于不熟悉日志分析工作区的任何人 - 可以在创建 Azure Application Insights 的新实例时指定它(请参阅屏幕)。

感谢大家努力帮助我!

更新:正如Jonathan L.在评论中提到的,无需创建新的Application Insights实例,只需更改属性中的工作区即可。