Azure-docs: Is there a way to ignore localhost telemetry in Application Insights?

Created on 25 May 2020  Â·  7Comments  Â·  Source: MicrosoftDocs/azure-docs

Hi,
I was wondering if Application Insights offers a feature to disable localhost telemetry, so that when building and testing my ASP.NET Core website in Visual Studio 2019, that telemetry data is not sent to Azure. I have to manually remove that data in the charts and metrics in the Azure portal, using filters, as my localhost data adds noise.

If you have any suggestion about accomplish this, it would be really helpful, thank you!

Regards,
Jorge Morales


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Azure-Monitosvc Pri1 application-insightsubsvc cxp product-question triaged

Most helpful comment

@jmoralesv You could remove the ikey from your local configuration so telemetry isn't pumped to Azure. Similar ideas have been discussed here and here.

Thanks @BhargaviAnnadevara-MSFT but those examples mentioned ApplicationInsights.config which no longer exists in .NET Core 3.x.

@jmoralesv if you only want to prevent the sending of telemetry you can also use:

https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#disable-telemetry-dynamically

I believe you could also wrap that in a preprocessor directive.

So something like:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddApplicationInsightsTelemetry();
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, TelemetryConfiguration configuration)
    {
#if DEBUG
    configuration.DisableTelemetry = true;
#endif
        ...
    }

Would probably get you closer to what you want.

Thanks @mrbullwinkle I think that could work as it's for .NET Core 3.x, I'll test that out in my local environment today and see how it goes, thank you!

All 7 comments

@jmoralesv, Thanks for the question! We are taking a look into this and will get back to you soon.

@jmoralesv You could remove the ikey from your local configuration so telemetry isn't pumped to Azure. Similar ideas have been discussed here and here.

@jmoralesv if you only want to prevent the sending of telemetry you can also use:

https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#disable-telemetry-dynamically

I believe you could also wrap that in a preprocessor directive.

So something like:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddApplicationInsightsTelemetry();
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, TelemetryConfiguration configuration)
    {
#if DEBUG
    configuration.DisableTelemetry = true;
#endif
        ...
    }

Would probably get you closer to what you want.

@jmoralesv You could remove the ikey from your local configuration so telemetry isn't pumped to Azure. Similar ideas have been discussed here and here.

Thanks @BhargaviAnnadevara-MSFT but those examples mentioned ApplicationInsights.config which no longer exists in .NET Core 3.x.

@jmoralesv if you only want to prevent the sending of telemetry you can also use:

https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#disable-telemetry-dynamically

I believe you could also wrap that in a preprocessor directive.

So something like:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddApplicationInsightsTelemetry();
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, TelemetryConfiguration configuration)
    {
#if DEBUG
    configuration.DisableTelemetry = true;
#endif
        ...
    }

Would probably get you closer to what you want.

Thanks @mrbullwinkle I think that could work as it's for .NET Core 3.x, I'll test that out in my local environment today and see how it goes, thank you!

@jmoralesv Is there anything else you'd like us to assist you with?

Hi @BhargaviAnnadevara-MSFT

@jmoralesv Is there anything else you'd like us to assist you with?

I think we can close this case, I can see there are no more localhost traces in Application Insights when using configuration.DisableTelemetry = true; in Debug mode.

Thank you so much for your help!

Regards,
Jorge

@jmoralesv Awesome, thanks for confirming. Happy to help!

We will now proceed to close this thread as resolved, but if there are any further questions regarding the documentation, please tag me in your reply and we will be happy to continue the conversation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bityob picture bityob  Â·  3Comments

JamesDLD picture JamesDLD  Â·  3Comments

monteledwards picture monteledwards  Â·  3Comments

mrdfuse picture mrdfuse  Â·  3Comments

jharbieh picture jharbieh  Â·  3Comments