Pester is a fantastic tool to test and monitor the status of your infrastructure. There are several libraries which leverage this directly (e.g. SQLChecks, DBAChecks, Operation Validation Framework), and a growing set of resources discussing how to leverage Pester in this fashion (including a Pluralsight course and a chapter in the Pester book). If you don’t already have some tests you can run interactively (is my environment correct right now?) I’d suggest you start there first.
Once you’ve got your infrastructure tests running interactively you’ll probably want to start automating them (is my environment correct every day?). And then at some point you’ll probably find yourself asking questions like:
- How long has this test been failing for?
- How long does this test normally take to run?
- When was the last time this test failed?
- How is the health of my estate trending over time?
Once you’ve invested time into building out a library of Pester tests for your infrastructure, what you really want to do is analyse the Pester test results. There are various examples out there that discuss how to persist results to files, XML, SQL databases - but none of these options have the advantages that shipping to Log Analytics provides - which is what we’ll discuss today. A few reasons why I think think sending your results to Log Analytics is the superior choice:
- Extremely powerful query language (KQL)
- Can be queried & consumed by a web browser, Power BI, REST API, Flow, Azure Monitor (for alerting)
- Lives with the rest of your infrastructure logs (if you use the machine agents/Azure connectors/etc.)
- Simplified security story (everywhere you run a tests posts to an HTTP endpoint - no fileshares/SQL databases/etc.)
- No impact on the systems under test (how many DBAs have spent time performance tuning their monitoring databases :)?)
- Great operating cost (free tier lets you log a lot of Pester results every month)
If you don’t already have a Log Analytics workspace I did a fairly detailed writeup last month: Getting started with Log Analytics and PowerShell logging.[Read More]