Azure Application Insights指标加载异常:新提交指标持续加载不显示
VS Code扩展遥测指标在Azure Application Insights加载异常排查方案
问题背景
开发VS Code扩展时,使用Azure Application Insights收集遥测数据,最初两个指标可正常在Metrics标签生成图表,但后续提交的thumbsUp指标一直显示加载状态(已持续2天),Investigate的Failures标签也无报错记录。
发送thumbsUp指标的代码片段:
this.reporter = new TelemetryReporter(this.key); this.reporter.sendTelemetryEvent('telemetryCollection', { 'stringProp': 'Numbers of times thumbs up is clicked' }, { 'thumbsUp': thumbsUp });
Azure界面显示状态:
具体排查步骤
检查Metrics页面聚合配置
新添加的数值型指标需要手动指定聚合方式(如求和、计数、平均值)。在Metrics标签页,确认是否为thumbsUp选择了正确的聚合函数,未配置的话会因无有效展示逻辑一直处于加载状态。用Logs验证数据接收情况
进入Logs标签页,执行以下Kusto查询,确认事件是否被Application Insights接收:union customEvents where name == 'telemetryCollection' and customDimensions.stringProp == 'Numbers of times thumbs up is clicked' project timestamp, customMeasurements.thumbsUp若查询无结果,说明事件未发送成功;若有结果,则问题出在Metrics展示层配置。
确认遥测配置有效性
- 检查Instrumentation Key/Connection String是否正确,对应的Application Insights资源是否正常、无权限限制。
- 确认VS Code扩展的
package.json中已声明network权限,保证扩展能正常发送网络请求。
验证指标数据类型
确保thumbsUp是数值类型(number),若传入的是字符串格式数值,Application Insights无法将其识别为可聚合指标,导致Metrics无法展示。排查采样策略
查看Application Insights的采样设置,是否开启高比例采样导致部分事件被丢弃。可对比Logs中的接收次数与实际发送次数,判断是否存在采样丢失。确认数据索引状态
首次发送新指标类型时,数据索引可能存在延迟。若Logs中能查到数据,可等待一段时间后再刷新Metrics页面。
内容的提问来源于stack exchange,提问作者Berry Cherolds
相关产品推荐
相关产品推荐

