我想禁用使用应用程序洞察的Azure函数的采样。我已经遵循了这些文档,但采样仍然启用。
Sampling in Application Insights
如何为Azure Functions配置监视
在Application Insights中,我使用以下查询来确定采样率:
dependencies
| where timestamp > ago(1d)
| summarize RetainedPercentage = 100/avg(itemCount) by bin(timestamp, 1h)
| order by timestamp desc
下面是我的host.json文件:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"LogLevel": {
"default": "Information"
},
"samplingSettings": {
"isEnabled": false
}
}
}
}
我也试过在代码中禁用采样:
var aiOptions = new ApplicationInsightsServiceOptions
{
EnableAdaptiveSampling = false,
InstrumentationKey = configuration.GetValue<string>("Telemetry:AppInsightsInstrumentationKey")
};
services.AddApplicationInsightsTelemetry(aiOptions);
1条答案
按热度按时间8i9zcol21#
如MSDOC中所述,默认情况下将为Azure函数启用自适应采样。
将设置***isEnabled***更改为***false***,如下图所示:
您也可以通过在ConfigureServices方法中使用以下代码来禁用采样:
运行以下查询以检查采样是否已禁用。
RetainedPercentage
应显示100%,如下所示:响应:

如果有助于解决问题,请检查以下故障排除步骤:
1.更新
host.json
文件中的采样设置后,重新启动Azure Function。1.还要验证您的代码并检查是否在Application Insights SDK配置中启用了采样。