Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable standard performance counters in Application Insights?

Standard performance counters in Application Insights generate too much volume. How can I disable them and only report my own counters + some standard ones (but not all), or just reduce sample frequency?

like image 365
LOST Avatar asked Mar 19 '17 18:03

LOST


People also ask

How do I turn off performance counter?

Select the server in server manager. Scroll down to the PERFORMANCE section. Right-click the server name, and there you find 'Stop Performance Counters'.

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.

What are performance counters in Windows?

Windows Performance Counters provide a high-level abstraction layer that provides a consistent interface for collecting various kinds of system data such as CPU, memory, and disk usage. System administrators often use performance counters to monitor systems for performance or behavior problems.


2 Answers

Adding this answer for asp.netcore users. modify your startup.cs as shown. You have two options. First completely disables the perf counters.

public void ConfigureServices(IServiceCollection services)
{

    var serviceDescriptor = services.FirstOrDefault(descriptor => descriptor.ImplementationType == typeof(PerformanceCollectorModule));
    services.Remove(serviceDescriptor);
}

or second removes individual counters and you can add your own if you want later.

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{

    var modules = app.ApplicationServices.GetServices<ITelemetryModule>();
    var perfModule = modules.OfType<PerformanceCollectorModule>().First();
    perfModule.DefaultCounters.Clear();

}
like image 190
AppLS Avatar answered Sep 19 '22 06:09

AppLS


In my case adding counters to Counters didn't affected the default counters so both sets mine and default was reported. Fortunately the collector is open source and there is a clear clue what you need to do in order remove them. Just define an empty DefaultCounters like this:

<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
    <DefaultCounters/>
    <Counters>
        <Add PerformanceCounter="YOUR COUNTER"/>
    </Counters>
</Add>
like image 42
igorushi Avatar answered Sep 20 '22 06:09

igorushi