简体   繁体   中英

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?

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>

Assuming you are using the latest .NET SDK, you can configure the performance counters or sampling ratio via the applicationinsights.config file.

In the Telemetry Processors section , you can set adaptive sampling by adding:

<TelemetryProcessors>
  <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
    <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
  </Add>
</TelemetryProcessors>

Setting specific performence counters can be in the Telemetry Modules section (see also this blog post ), for example:

<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
  <Counters>
    <Add PerformanceCounter="\Process(??APP_WIN32_PROC??)\Handle Count" ReportAs="Process handle count" />
  </Counters>      
</Add>

Removing the PerfCounterCollector type will disable performance counters collection altogether.

Asaf

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();

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM