[英]Heartbeat functionality from AppInsights does not appear in azure portal
我正在嘗試使 AppInsights sdk 的心跳功能正常工作,但遇到了一些麻煩。
我有一個簡單的應用程序(只是使用 dotnet new webapp 創建的默認 ASP.net core 2.2 項目)在 Azure 內的 k8 集群上運行,並配置了以下設置:
public void ConfigureServices(IServiceCollection services)
{
ApplicationInsightsServiceOptions aiOptions
= new ApplicationInsightsServiceOptions();
// Disables adaptive sampling.
aiOptions.EnableAdaptiveSampling = false;
// Disables QuickPulse (Live Metrics stream).
aiOptions.EnableQuickPulseMetricStream = false;
aiOptions.InstrumentationKey = InstrumentationKey;
aiOptions.EnableHeartbeat=true;
services.AddApplicationInsightsTelemetry(aiOptions);
services.Configure<CookiePolicyOptions>(options =>
{
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddApplicationInsightsKubernetesEnricher();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
但是,我在 Application Insights 中看不到與心跳功能相關的任何屬性。 我可以看到其他內容,例如 kubernetes pod 名稱等。
我錯過了一些配置嗎?
謝謝你。
從基本SDK 2.5.0開始默認啟用心跳功能,並且2.3.0-beta1中添加了配置心跳的功能。
我建議您如下修改啟動文件:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
ApplicationInsightsServiceOptions aiOpts =
new ApplicationInsightsServiceOptions();
aiOpts.EnableHeartbeat = true; // false to disable
services.AddApplicationInsightsTelemetry(aiOpts);
...
}
還using Microsoft.ApplicationInsights.AspNetCore.Extensions;
添加using Microsoft.ApplicationInsights.AspNetCore.Extensions;
在文件頂部。 通過直接修改IHeartbeatPropertyManager
在代碼中配置心跳功能。 當您首次通過TelemetryModules.Instance
單例獲得屬性管理器時,可以執行此操作。
foreach (var md in TelemetryModules.Instance.Modules)
{
if (md is IHeartbeatPropertyManager heartbeatPropertyMan)
{
heartbeatPropertyMan.HeartbeatInterval = TimeSpan.FromMinutes(5.0);
heartbeatPropertyMan.ExcludedHeartbeatProperties.Add("osType");
...
試試這個,看看是否有幫助。
要查詢心跳事件,您可以使用以下 KQL 查詢:
customMetrics
| where name == "HeartbeatState"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.