skip to Main Content

I am logging custom events from my ASP.NET Core 8 Web API. I can see those events display in Live Metrics shortly after they are sent, but I’m not able to find them in any of the ‘events’ tables to query later.

I’ve checked in the ‘customEvents’ table in Log Analytics, and I’ve also checked the ‘AppEvents’ table in my Log Analytics Workspace. It has been more than 24 hours since those events were seen in Live Metrics, which I assume is more than enough time for processing to occur. Is there something I’m missing?

I am running a custom ITelemetryInitializer, but it only operates on request and dependency telemetry:

public class TelemetryInitializer : ITelemetryInitializer
{
    public void InitializeTelemetry(ITelemetry telemetry)
    {
        if (telemetry is DependencyTelemetry dependency)
        {
            // manipulate dependency data
        }

        if (telemetry is RequestTelemetry request)
        {
            // manipulate request data
        }
    }
}

Most of my configuration is accomplished in appsettings.json:

"ApplicationInsights": {
    "InstrumentationKey": "redacted",
    "DeveloperMode": false,
    "EnableAdaptiveSampling": true,
    "EnableRequestTrackingTelemetryModule": true,
    "EnablePerformanceCountersCollectionModule": false,
    "EnableActiveTelemetryConfigurationSetup": true,
    "InitialSamplingPercentage": 5,
    "SamplingSettings": {
      "MaxTelemetryItemsPerSecond": 5,
      "ExcludedTypes": "Event",
      "IncludedTypes": "Exception;Dependency;Trace;Request"
    }
}

I suspect AdaptiveSampling has something to do with it, but I’m not sure why that would allow me to see it in Live Metrics and then not in the table afterwards.

EDIT:

I was asked to provide my Program.cs file, but for these purposes, my ApplicationInsights registration is all happening in Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    services.AddApplicationInsightsTelemetry(options =>
    {
        Configuration.GetSection("ApplicationInsights")
                     .Bind(options);
    });

    services.AddSingleton<ITelemetryInitializer, TelemetryInitializer>();
}

2

Answers


  1. Chosen as BEST ANSWER

    From what I can tell, the problem here seems to be the Daily Data Cap that we've set for this instrumentation key on the Azure side. MS documentation indicates that reaching the daily cap should block "all billable data from being ingested", but it seems that "ingested" may be referring only to the underlying tables where this information would be queryable, and not necessarily blocking telemetry from hitting AppInsights altogether.

    I'm now using an entirely separate instrumentation key that does not have the same limitations, and I've been able to see my events in both Live Metrics and Log Analytics.


  2. I am able to see the Custom Events in Live Metrics, Transaction Search and Logs in Application Insights with the default and the configuration which you have shared.

    Live Metrics:
    enter image description here

    Transaction Search:

    enter image description here

    Logs – Application Insights:
    enter image description here

    and as well as in LogAnalytics – AppEvents Table.

    enter image description here

    My Program.cs file:

    builder.Services.AddApplicationInsightsTelemetry(new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions
    {
        ConnectionString = builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]
    });
    

    My TelemetryInitializer.cs file:

    private readonly TelemetryClient _tc;
    if (telemetry is EventTelemetry eventTel)
    {
        if (eventTel.Name == "CustomEventName" && eventTel.Properties.ContainsKey("CustProp1"))
        {
            _tc.TrackEvent(eventTel.Name, eventTel.Properties, eventTel.Metrics);
        }   
    }
    

    My Controller Class:

    With EventTelemetry:

     private readonly TelemetryClient _tc;
     public WeatherForecastController(TelemetryClient tc,ILogger<WeatherForecastController> logger)
     {
        _tc = tc;
         logger = logger;
     }
     [HttpGet(Name = "GetWeatherForecast")]
     public IEnumerable<WeatherForecast> Get()
     { 
         var customEventTel = new EventTelemetry("CustomEventName");
         customEventTel.Properties.Add("CustomProperty", "SamValTest1");
         _tc.TrackEvent(customEventTel);
         ------
     }
    

    Without EventTelemetry:

     _tc.TrackEvent("CustomEventName", new Dictionary<string, string>
     {
        { "CustProp1", "SamValTest1" },
        { "CustProp2", "SamValTest2" }
     });
    

    I suspect AdaptiveSampling has something to do with it,

    • Adaptive Sampling helps to reduce the telemetry data for the configured properties.
    • Yes, the issue seems to be with your Adaptive Sampling Configuration.
    • Remove the "ExcludedTypes": "Event", from appsettings.json file and check once.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search