3
votes

A large part of my telemetry quota for Application Insights is being used up by ping requests for SignalR (and other SignalR requests).

How can I prevent these requests from being reported? I want to keep other ajax requests, but apply some kind of (client side) filter for SignalR requests.

I haven't been able to find any good documentation that provides easy examples. I know that I can filter out some requests using the addTelemetryInitializer, but I don't know what to filter on?

    appInsights.queue.push(function () {
        appInsights.context.addTelemetryInitializer(function (envelope) {
            // What should I do here to remove /signalr requests?
        });
    });
1

1 Answers

9
votes

In your scenario I am assuming you would like to filter our Ajax remote dependency calls issued by browser. To filter our server-side signalr requests from telemetry you will need to implement telemetry processor on the server side (https://azure.microsoft.com/en-us/blog/request-filtering-in-application-insights-with-telemetry-processor/)

It would be something like this. Cannot validate right now, so will fix any syntax errors later:

window.appInsights = appInsights;
// Add telemetry initializer
appInsights.queue.push(function () {

appInsights.context.addTelemetryInitializer(function (envelope) {

/* filter our Ajax requests with signalr in url*/

if (envelope.name === Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData.envelopeType && envelope.data.baseData.commandName.indexOf("signalr")>-1){

   return false;

 }
});
});

// end of insertion

appInsights.trackPageView();

Please see this for more examples on JS telemetry initializer: https://blogs.msdn.microsoft.com/albulank/2016/04/20/modifying-and-filtering-telemetry-with-appinsights-javascript-sdk-telemetry-initializer/