How to use Application Insights in more than one application?

Asked

Viewed 105 times

5

It is possible to use the Application Insights in more than one application and in Azure I have to filter the data of each application separately ?

  • What problem you want to solve using a App Insights screen for multiple applications?

  • Separate information from each application in the Insights app.

1 answer

6


Application Insights can be used in more than one application?

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

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

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

To filter, you can add a 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 start to charge you after a few Giga of bigdata stored, which can take a long time. If you share the service, you will reach that billing start line faster, when you have a service per app, it will be much harder to cross that limit.

  • Cool Thiago, I will evaluate and see how to solve, then I come back to give the acceptance.

  • Okay @Marconciliosouza

  • @Marconciliosouza added an example code. See if it improves the answer.

  • Thiago, I didn’t understand exactly what it would be (just add your processor to the main service), sorry, but new in this matter. If I had more detail would be cool,l even because there is not much content on this subject in the SO-PT.

  • When you add Appinsights to your application, it has a configurator TelemetryConfiguration. It is a global configurator. Just add your processor MeuFiltroTelemetryProcessor on it every tracking, will call your filter.

  • Man you got exactly where I wanted, vlw even.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.