0
votes

I have an ASP.NET website hosted on Azure with Application Insights. Azure Application Insights works fine, however I noticed Application Insights is taking a lot of snapshots for HTTP 404 errors. This is not really useful to me as the 404 error are mostly generated by random online mass scanners. I was wondering if there is way to configure Application Insights not to take snapshots of HTTP 404 errors but still log the exception ?

Thanks

1

1 Answers

0
votes

Yes, you can for instance create a custom telemetry processor. This blog post has an example to filter out 403 - you can do the same for 404s https://azure.microsoft.com/en-us/blog/request-filtering-in-application-insights-with-telemetry-processor/

Like this should work:

public void Process(ITelemetry item)
{
    var request = item as RequestTelemetry;

    if (request != null &&
    request.ResponseCode.Equals("404", StringComparison.OrdinalIgnoreCase))
    {
        // To filter out an item, just terminate the chain: 
        return;
    }
    // Send everything else: 
    this.Next.Process(item);
}