This article applies to: ✓ .NET Core 3.0 SDK and later versions
dotnet tool install --global dotnet-counters
dotnet-counters [-h|--help] [--version] <command>
dotnet-counters is a performance monitoring tool for ad-hoc health monitoring and first-level performance investigation. It can observe performance counter values that are published via the EventCounter API. For example, you can quickly monitor things like the CPU usage or the rate of exceptions being thrown in your .NET Core application to see if there's anything suspicious before diving into more serious performance investigation using
Displays the version of the dotnet-counters utility.
Shows command-line help.
Displays a list of counter names and descriptions, grouped by provider.
dotnet-counters list [-h|--help]
> dotnet-counters list Showing well-known counters only. Specific processes may support additional counters. System.Runtime cpu-usage Amount of time the process has utilized the CPU (ms) working-set Amount of working set used by the process (MB) gc-heap-size Total heap size reported by the GC (MB) gen-0-gc-count Number of Gen 0 GCs / sec gen-1-gc-count Number of Gen 1 GCs / sec gen-2-gc-count Number of Gen 2 GCs / sec exception-count Number of Exceptions / sec
Displays periodically refreshing values of selected counters.
dotnet-counters monitor [-h|--help] [-p|--process-id] [--refreshInterval] [counter_list]
The ID of the process to be monitored.
The number of seconds to delay between updating the displayed counters
A space separated list of counters. Counters can be specified
provider_name[:counter_name]. If the
provider_nameis used without a qualifying
counter_name, then all counters are shown. To discover provider and counter names, use the dotnet-counters list command.
Monitor all counters from
System.Runtimeat a refresh interval of 3 seconds:
> dotnet-counters monitor --process-id 1902 --refresh-interval 3 System.Runtime Press p to pause, r to resume, q to quit. System.Runtime: CPU Usage (%) 24 Working Set (MB) 1982 GC Heap Size (MB) 811 Gen 0 GC / second 20 Gen 1 GC / second 4 Gen 2 GC / second 1 Number of Exceptions / sec 4
Monitor just CPU usage and GC heap size from
> dotnet-counters monitor --process-id 1902 System.Runtime[cpu-usage,gc-heap-size] Press p to pause, r to resume, q to quit. System.Runtime: CPU Usage (%) 24 GC Heap Size (MB) 811
EventCountervalues from user-defined
EventSource. For more information, see Tutorial: How to measure performance for very frequent events using EventCounters.
> dotnet-counters monitor --process-id 1902 Samples-EventCounterDemos-Minimal Press p to pause, r to resume, q to quit. request 100