Azure Application Insights仅显示1个用户/会话问题求助
Azure Application Insights 用户/会话计数异常排查
环境与问题
- 架构:前端基于React+Node.js,后端为C# API,分别部署在两个独立的Azure App Service中
- 异常现象:API后端关联的Application Insights始终仅统计1个用户、1个会话,但实际已通过两个不同IP地址发起测试,且日志已记录对应访问;事件、错误等其他遥测数据均能正常采集,仅用户/会话计数不符合实际情况
已执行的排查操作
- 初始配置:在Azure门户创建Application Insights资源并关联API App Service,问题未解决
- 项目内配置:在Visual Studio项目中手动配置并关联现有Instrumentation Key,无效
- 代码手动设置用户/会话ID:
Kudu日志显示不同测试请求的IP已正确赋值,但Application Insights仪表板仍显示1个用户/会话,且User Id、Session Id字段显示为var telemetryClient = new TelemetryClient(); telemetryClient.InstrumentationKey = "123"; var ipAddress = HttpContext.Connection.RemoteIpAddress.ToString(); if (ipAddress == "::1") { ipAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[1].ToString(); } telemetryClient.Context.User.Id = ipAddress; telemetryClient.Context.User.AuthenticatedUserId = ipAddress; telemetryClient.Context.Session.Id = ipAddress; logger.LogInformation("User.Id -> " + ipAddress); logger.LogInformation("User.AuthenticatedUserId -> " + ipAddress); logger.LogInformation("Session.Id -> Ip -> " + ipAddress);<undefined> - 前端配置尝试:安装
applicationinsights@^2.7.2,在webpack.js和index.html中添加配置,本地环境测试用户/会话计数正常,但部署到Azure App Service后问题依旧,遥测中Session.Id已赋值但统计结果仍异常
内容的提问来源于stack exchange,提问作者John
相关产品推荐
相关产品推荐

