【发布时间】:2022-01-11 14:20:48
【问题描述】:
我有一个作为 Azure 应用服务运行的 ASP.NET Core 应用程序。 Azure Application Insights 已启用(我关注了these instructions)。问题是我在 Azure 门户上的 Azure Insights 实例没有显示任何有用的数据,除了实时指标 (see the screenshot)。如您所见,屏幕截图中有多个请求和自定义事件。
但是,当我打开事务搜索时,它什么也没有显示 (see the screenshot)。 活动页面也是空的 (see the screenshot)。
到目前为止,我仔细检查了一个 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);
});
下面是 Startup.cs 的代码:
services.AddApplicationInsightsTelemetry(new ApplicationInsightsServiceOptions
{
ConnectionString = Environment.GetEnvironmentVariable("APPLICATIONINSIGHTS_CONNECTION_STRING")
});
logLevel也在appsettings.json中配置:
"Logging": {
"LogLevel": {
"Default": "Warning"
},
"ApplicationInsights": {
"LogLevel": {
"Default": "Information"
}
}
更新: 拥有更多权限的管理员可以看到所有数据,包括事件、性能操作等。所以我想这与权限有关。虽然奇怪的是我没有看到任何警告信息。管理员为我分配了更多角色 (see the screenshot),但没有任何区别。
我将不胜感激有关此问题的任何帮助!
【问题讨论】:
-
尝试记录一些虚假警告(使用 ILogger),或将日志级别降低到信息,并记录信息级别消息并检查是否出现 - 通常需要 3 到 5 分钟才能出现在App Insights 门户页面/图表。
-
阅读这个常见问题解答的特别section。
-
@AnandSowmithiran,感谢您的建议,但没有帮助。我什至将我的日志级别设置为 Trace。 Live Metrics 页面现在在 Sample telemetry 部分中显示了许多 Trace 事件。所以看起来 Application Insights 正在接收数据,但没有保存它......
-
查看此SO question 的答案,有时未正确输入 Instrumentation 密钥。
-
您是在单独使用
ILogger还是(也)TelemetryClient?您可以发布设置检测密钥和日志级别的代码/配置吗?
标签: asp.net azure .net-core azure-application-insights