How to use Application Insights in more than one application?

5

Is it possible to use Application Insights in more than one application and in Azure I have how to filter the data for each application separately?

    
asked by anonymous 29.06.2017 / 04:04

1 answer

6
  

Is it possible to use Application Insights in more than one application?

YES! There is no restriction on this. It is even common to use a single service for backend metrics - API - and clients - WEB, Mobile, etc. But, it's not very easy to manage this later.

  

... and in Azure I have how to filter the data of each application separately?

Exactly here is the problem, if everything is part if the same software - backend, client mobile - even gives to consider. But being system different, besides not being easy to separate after, there is no reason to do this.

In order to be able to filter, you can add ITelemetryProcessor to intercept the trackings .

public class MeuFiltroTelemetryProcessor : ITelemetryProcessor
{
    private ITelemetryProcessor Next { get; set; }

    public MeuFiltroProcessor(ITelemetryProcessor next)
    {
        Next = next;
    }

    public void Process(ITelemetry item)
    {
        var request = item as RequestTelemetry;
        if (request == null)
        {
            Next.Process(item);
            return;
        }

        if (request.VeioDoBackend())
        {
            request.Context.Properties["Backend"] = "true";
        }
        else if (request.VeioDoWebsite())
        {
            request.Context.Properties["Website"] = "true";
        }
        else if (request.VeioDoMobileApp())
        {
            request.Context.Properties["MobileApp"] = "true";
        }

        Next.Process(item);
    }
}

Then just add your processor to the main service:

var builder = TelemetryConfiguration.Active.TelemetryProcessorChainBuilder;
builder.Use(next => new MeuFiltroTelemetryProcessor(next));
builder.Build();

Now, via AppInsights portal, just filter by Backend , WebSite or MobileApp .

There is no cost to have numerous AppInsights services. Current plans only begin to charge you after some stored Giga of bigdata, which can take a lot of time. If you share the service, you'll reach that charging start line faster, so if you have one service per app, it's much harder to cross that limit.

    
29.06.2017 / 08:42