Can URLs be excluded from the Insights app?

We have a deployed Azure web role using Application Insights (version 1.0.0.4220), but we are moving on to our data quota. Can I configure Application Insights to ignore a specific URL?

We have a status web service that receives a huge amount of traffic but never causes errors. If I could exclude this service URL, then I could cut back on my data usage in half.

+12
source share
3 answers

Out of the box, this is not supported. The fetch function is approaching, but it will not be configured for a specific URL. You can implement your own channel, which will have its own filtering. Basically, your channel will receive an event to send, you check whether you want to send it or not, and then, if so, go to the standard AI channel. Here you can learn more about custom channels.

Two things have changed since this blog post was written:

  • the channel should implement only the ITelemetryChannel interface (ISupportConfiguration has been removed)
  • and instead of PersistenceChannel you should use Microsoft.ApplicationInsights.Extensibility.Web.TelemetryChannel

UPDATE: the latest version has filtering support: https://azure.microsoft.com/en-us/blog/request-filtering-in-application-insights-with-telemetry-processor/

+7
source

My team had a similar situation where we needed to filter out URLs that were successful image images (we had a lot of these, which is why we reached the limit of 3000 dots / min).

As a result, we used a modified version of this class on a blog in a blog to filter them out.

We created the RequestFilterChannel class, which is an instance of ServerTelemetryChannel and extended the Send method. In this method, we check every telemetry element that will be sent to see if this is a request for an image, and if so, we prevent it from being sent.

 public class RequestFilterChannel : ITelemetryChannel, ITelemetryModule { private ServerTelemetryChannel channel; public RequestFilterChannel() { this.channel = new ServerTelemetryChannel(); } public void Initialize(TelemetryConfiguration configuration) { this.channel.Initialize(configuration); } public void Send(ITelemetry item) { if (item is RequestTelemetry) { var requestTelemetry = (RequestTelemetry) item; if (requestTelemetry.Success && isImageRequest((RequestTelemetry) item)) { // do nothing } else { this.channel.Send(item); } } else { this.channel.Send(item); } } public bool? DeveloperMode { get { return this.channel.DeveloperMode; } set { this.channel.DeveloperMode = value; } } public string EndpointAddress { get { return this.channel.EndpointAddress; } set { this.channel.EndpointAddress = value; } } public void Flush() { this.channel.Flush(); } public void Dispose() { this.channel.Dispose(); } private bool IsImageRequest(RequestTelemetry request) { if (request.Url.AbsolutePath.StartsWith("/image.axd")) { return true; } return false; } } 

After creating the class, you need to add it to the ApplicationInsights.config file.

Replace this line:

 <TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/> 

with reference to your class:

 <TelemetryChannel Type="XXX.RequestFilterChannel, XXX" /> 
+4
source

Alternatively, you can disable the automatic query collection and save only the exception collection, just remove the RequestTrackingModule line from applicationinsights.config.

If you still need to collect some of the requests, and not just filter everything, you can call TrackRequest () (in the object of the TelemetryClient class) from your code in the appropriate place after you know that you definitely need to register this request for AI.

+2
source

Source: https://habr.com/ru/post/990057/


All Articles