Application Insights Java Agent 3.5.4过滤特定依赖遥测失败求助
解决方案
1. 确认依赖遥测的准确属性键
不同版本的Azure Application Insights Java Agent对依赖项的属性键命名可能有差异,建议:
- 添加启动参数
-Dapplicationinsights.debug=true启用调试日志,查看该依赖遥测的完整属性列表,确认目标属性的准确键名。 - 或在Azure Portal的Application Insights中查看该依赖遥测的自定义属性,核实具体键值。
2. 修正采样规则的位置与格式
确保过滤规则添加到sampling.overrides数组内(而非单独的notWorkingFilters),针对localhost:5778的依赖,正确配置示例如下:
{ "sampling": { "percentage": 100, "overrides": [ // 保留原有有效规则 { "telemetryType": "request", "attributes": [ { "key": "http.url", "value": "https?://[^/]+/health.*", "matchType": "regexp" } ], "percentage": 0 }, { "telemetryType": "request", "attributes": [ { "key": "http.url", "value": "https?://[^/]+/metrics.*", "matchType": "regexp" } ], "percentage": 0 }, { "telemetryType": "request", "attributes": [ { "key": "http.request.method", "value": "HEAD", "matchType": "strict" } ], "percentage": 0 }, { "telemetryType": "trace", "percentage": 0 }, // 添加依赖过滤规则 { "telemetryType": "dependency", "attributes": [ { "key": "http.url", "value": "http://localhost:5778/.*", "matchType": "regexp" } ], "percentage": 0 } ] }, "instrumentation": { "jdbc": { "masking": { "enabled": false } } } }
3. 升级Agent版本
若使用旧版Agent,采样覆盖规则对依赖项的支持可能不完善,建议升级至最新稳定版。
4. 直接禁用特定依赖的检测
如果采样规则仍不生效,可在instrumentation部分直接排除该依赖:
{ "instrumentation": { "jdbc": { "masking": { "enabled": false } }, "http": { "exclusions": [ "http://localhost:5778/.*" ] } } }
内容的提问来源于stack exchange,提问作者lhn_dk
相关产品推荐
相关产品推荐

