tuol
tuol

Reputation: 21

Don't record telemetry for static files in Application insights

I`m logging telemetry in Application Insights for a .NET Framework 4.7.2 web application running on Azure App Service.

A lot of telemetry comes from static file requests like .js and .css files and is not interesting to me. Since it incurs storage costs, it would be better not to log them at all.

One of the ideas towards a solution is to filter ITelemetry items in a class implementing the ITelemetryProcessor interface, based on the url of the request.

public void Process(ITelemetry item)
{
    if (item is RequestTelemetry request && request.Url.AbsolutePath.EndsWith(".js", StringComparison.OrdinalIgnoreCase))
    {
        return;
    }

    this.Next.Process(item);
}

I suspect there might be more reliable / more effective ways accomplish what I want. Anyone?

Upvotes: 2

Views: 756

Answers (1)

Dmitry Matveev
Dmitry Matveev

Reputation: 2679

You may try disabling processing of static files through managed handlers in web.config:

<modules runAllManagedModulesForAllRequests="true"> ... coupled with preCondition="managedHandler" on the AI-specific module.

This will ensure that AI module does not process requests to static files. If that fails, using Telemetry Processor as you suggested is the next best thing.

Upvotes: 1

Related Questions