This is a simple post detailing how you can use PowerShell to quickly check the health of an application that uses Metrics.NET. For anyone who doesn’t know, Metrics.Net is a library that provides a way of instrumenting applications with custom metrics (timers, histograms, counters, etc) that can be reported in various ways and can provide insights on what is happening inside a running application.
The idea behind using PowerShell to query Metrics.NET health checks is that this script could be given to people in operations who can then monitor the help of the application without requiring knowledge of Metrics.NET or JSON. A message is also sent to the related developer’s slack channel so they get a heads up that something isn’t healthy and get in-front of the issue before it’s reported :-)
To make this as re-usable as possible and cleaner to read, I created two PowerShell scripts, one containing the functions and the other for running the health checks.
Here’s the script I’ve called ‘_MetricsDotNetHealthCheck.ps1’ which contains the PowerShell functions.
Finally, here’s an example script to perform the health checks:
Bingo, a quick and easy to use solution for gathering and checking the health of multiple applications which implement the Metrics.NET library. Enjoy!