Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to exclude a url from Application Insights?

We have an Azure web role deployed that has been using Application Insights (ver. 1.0.0.4220), however, we're going over our data quota. Is it possible to configure Application Insights ignore a specific URL?

We have a status web service that gets a huge amount of traffic but never throws any errors. If I could exclude this one service URL I could cut my data usage in half.

like image 673
Greg Enslow Avatar asked Jun 30 '15 22:06

Greg Enslow


People also ask

How do I see exceptions in application insights?

Diagnose exceptions using Visual StudioOpen the Application Insights Search telemetry window in Visual Studio. While debugging, select the Application Insights dropdown box. Select an exception report to show its stack trace. To open the relevant code file, select a line reference in the stack trace.

How do I query traces in application insights?

View logs in Application InsightsGo to Logs under Monitoring section. Click on traces eye button to get log traces. Select Time Range and click Run. Application Insights queries are based on Kusto Query Language(KQL).

Does application insights affect performance?

The Application Insights SDK and instrumentation is designed to be extremely lightweight and have minimal impact on the performance of your application.

How do I remove logs from application insights?

The only way to do that is to delete the entire Application Insights service configuration through the portal. And currently Application Insights has 7 days retention policy, so all data will be deleted automatically in 7 days.


2 Answers

Out of the box it is not supported. Sampling feature is coming but that would not be configurable by specific url. You can implement your own channel that would have your custom filtering. Basically your channel will get event to be sent, you check if you want to send it or not and then if yes pass to standard AI channel. Here you can read more about custom channels.

There are two things that changed since this blog post has been written:

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

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

like image 53
Anastasia Black Avatar answered Oct 15 '22 14:10

Anastasia Black


My team had a similiar situation where we needed to filter out urls that were successful image requests (we had a lot of these which made us hit the 30k datapoints/min limit).

We ended up using a modified version of the class in Sergey Kanzhelevs blog post to filter these out.

We created a RequestFilterChannel class which is an instance of ServerTelemetryChannel and extended the Send method. In this method we test each telemetry item to be sent to see if it is an image request 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;
    }
}

Once the class has been created you need to add it to your ApplicationInsights.config file.

Replace this line:

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

with a link to your class:

<TelemetryChannel Type="XXX.RequestFilterChannel, XXX" />  
like image 30
Rune Vejen Petersen Avatar answered Oct 15 '22 13:10

Rune Vejen Petersen