Search code examples
asp.net-coreblazor-server-sideazure-application-insights

Where do custom metrics I did not set come from


I explicitly track 4 metrics in my app and they all show up in the Azure Application Insights custom metrics. But this list of metrics also has 3 metrics I did not set:

  • HealthReportEntryDuration
  • HeartbeatState
  • TotalDuration

What are these and where did they come from? I do have Health Checks enabled. Also, the 1st & 3rd of these has numbers while the 2nd is flatlined at 0.

enter image description here


Solution

  • Thanks @Peter Bons's for the Answer.

    In addition, Please check the below Workaround.

    I have created a sample Application Insights with default settings.

    I haven't configured anything neither enabled Application Insights for my App.

    Initially I don't see any metrics which you have mentioned.

    • I have just configured Application Insights from Connected Services in VS and deployed the app to Azure App Service.

    • Now Iam able to see the HeartbeatState metric.

    enter image description here

    • You can also see the namespace details.
    • I can see this metrics for all my available applications which I have deployed

    AFAIK, HealthReportEntryDuration and TotalDuration are related to HealthCheck. Based on the installed packages related to the health check they might have enabled.

    • I have configured HealthCheck in my app.

    My Program.cs file:

    builder.Services.AddApplicationInsightsTelemetry(new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions
    {
        ConnectionString = builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]
    });
    builder.Services.AddHealthChecks()
        .AddCheck("SampleCheck", () => HealthCheckResult.Healthy(), tags: new[] { "sample" })
        .AddApplicationInsightsPublisher(); 
    

    As per this MSDoc, totalDuration comes under Browser metrics.

    To collect browser metrics, your application must be instrumented with the Application Insights JavaScript SDK.

    so configured JavaScript SDK as well.

    • Now I am able to see the metrics which you have mentioned.

    enter image description here

    Also refer this MSDoc on Monitoring data reference -Azure Monitor for more details.