This post shows how to collect Performance Counters for the desktop application and features the answer to the questions:
There is no more “TelemetryModules“ collection in “TelemetryConfiguration“ class. where should I store my telemetry modules?
Install NuGet package.
NuGet will create an
ApplicationInsights.config file. If you don’t use it (and you probably don’t use it for desktop applications) - remove this file.
Define global variable that will live for a lifetime of an application, instantiate it, populate the list of counters and call
1 2 3 4 5 6 7 8 9 10 11 12 13
In order to collect counters for the current process - you should use
??APP_CLR_PROC?? for CLR counters and
??APP_WIN32_PROC?? for windows counters. Typically counter instances will be named after process name. However in case of multiple instances of the process running you will have names like
w3wp#3 representing third instance of the
This indeces in instance names will change over time. For example, when process
w3wp#2 will finish,
w3wp#3 will become
w3wp#2. Moreover, instance name for CLR counters is different than for windows counter as CLR counters only count processes that runs .NET code inside.
PerfCounterCollector will regularly check the mapping between the instance name and process ID using counters:
\.NET CLR Memory(*)\Process ID for managed counters and
Process(*)\ID Process for windows counters is you are using keywords
??APP_WIN32_PROC?? as instance names.
You are all set. Counter will be sent to the portal every minute.
Custom counters will be sent as metrics:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Standard perofrmance counters will be sent as performance counters:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
For web applications you can configure the list of performance counters to monitor using configuration file.
Note, that for SDK to collect counters identity application is running under should be part of the group
Performance Monitor Users.