Custom Metrics stop saving in App Insight after one hour

34 Views Asked by At

I am using Azure services in my application (AppService, AppInsight)

Also, I've implemented my project int .net Core6

I am using Microsoft.ApplicationInsights.AspNetCore library (version 2.22.0)

My Application Insight configuration in appsetting.json is like this

  "ApplicationInsights": {
     "ConnectionString": "InstrumentationKey=a91c943b-5268-42e1-80c3-dc03c5e9bf0c;IngestionEndpoint=https://easteurope.in.applicationinsights.azure.com/;LiveEndpoint=https://easteurope.livediagnostics.monitor.azure.com/"
 }

I've registered the Application insight service like this:

builder.Services.AddApplicationInsightsTelemetry();

and my code is

private readonly TelemetryClient telemetryClient;

public SaveMetricsUseCase(TelemetryClient telemetryClient)
{
    this.telemetryClient = telemetryClient;
}

...

private void SaveMetrics() {

   telemetryClient.GetMetric("ProjectName.PromptTokens", "CategoryId", "Model", "UserId")
      .TrackValue(input.Prompt, input.CategoryId, input.ModelName, input.UserId);

   telemetryClient.GetMetric("ProjectName.CompletionTokens", "CategoryId", "Model", "UserId")
      .TrackValue(input.Completion, input.CategoryId, input.ModelName, input.UserId);
}

Whenever I deploy my changes on AppService, the custom metrics are saved properly but after one hour the metrics stop storing and I can not see any metrics in the App Insight portal anymore (other logs and exceptions saved in AppInsight without problem, only metrics do not store anymore)

Have you any idea what the problem might be?

0

There are 0 best solutions below