Skip to main content

Using Event Counters with Application Insights

When adding the Application Insights SDK to your application, a set of Performance Counters is tracked by default.

This is the list of default counters for ASP.NET web applications:

  • % Process\Processor Time
  • % Process\Processor Time Normalized
  • Memory\Available Bytes
  • ASP.NET Requests/Sec
  • .NET CLR Exceptions Thrown / sec
  • ASP.NET ApplicationsRequest Execution Time
  • Process\Private Bytes
  • Process\IO Data Bytes/sec
  • ASP.NET Applications\Requests In Application Queue
  • Processor(_Total)\% Processor Time

However Performance Counters are a windows only feature. With .NET being cross-platform, is there a solution that works on both Windows and Linux?

Of course there is! (Otherwise I wouldn’t be writing this blog post).

Collecting EventCounters with Application Insights

The documentation has the following to say about EventCounters:

EventCounter is .NET/.NET Core mechanism to publish and consume counters or statistics. EventCounters are supported in all OS platforms - Windows, Linux, and macOS. It can be thought of as a cross-platform equivalent for the PerformanceCounters that is only supported in Windows systems.

By default no EventCounters are collected, but they are easy to add by configuring the EventCounterCollectionModule:

Probably the hardest thing when implementing EventCounters is finding the list of built-in counters.

Here is an example where I added some extra EventCounters from ASP.NET Core:

Viewing EventCounters data in Application Insights

To view the tracked EventCounters, you need to look at the ‘Custom’ category inside the Log-based metrics namespace:


Popular posts from this blog

DevToys–A swiss army knife for developers

As a developer there are a lot of small tasks you need to do as part of your coding, debugging and testing activities.  DevToys is an offline windows app that tries to help you with these tasks. Instead of using different websites you get a fully offline experience offering help for a large list of tasks. Many tools are available. Here is the current list: Converters JSON <> YAML Timestamp Number Base Cron Parser Encoders / Decoders HTML URL Base64 Text & Image GZip JWT Decoder Formatters JSON SQL XML Generators Hash (MD5, SHA1, SHA256, SHA512) UUID 1 and 4 Lorem Ipsum Checksum Text Escape / Unescape Inspector & Case Converter Regex Tester Text Comparer XML Validator Markdown Preview Graphic Color B

Help! I accidently enabled HSTS–on localhost

I ran into an issue after accidently enabling HSTS for a website on localhost. This was not an issue for the original website that was running in IIS and had a certificate configured. But when I tried to run an Angular app a little bit later on http://localhost:4200 the browser redirected me immediately to https://localhost . Whoops! That was not what I wanted in this case. To fix it, you need to go the network settings of your browser, there are available at: chrome://net-internals/#hsts edge://net-internals/#hsts brave://net-internals/#hsts Enter ‘localhost’ in the domain textbox under the Delete domain security policies section and hit Delete . That should do the trick…

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.