Do you rely on Windows Performance Monitor discover the root cause of production performance issues? Are you still struggling with creating lots of performance monitors at once or simply need a way to automate the process? If so, this article is for you.

In this article, you’ll learn how to configure Windows Performance Monitor by building XML performance monitoring templates to save yourself valuable time.

How Templates Work in Windows Performance Monitoring

Windows Performance Monitor (perfmon) is a native Windows tool for administrators to specify attributes like performance counters, event tracing for Windows events, and system configuration items. Once the attributes are set, perfmon captures data into one of several formats: binary log, SQL, Data Source Name (DSN), or CSV.

Only capture the data you need via performance monitoring. If not, you risk negatively affecting the performance of your servers!
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/45a0023e-7d06-4d7d-af20-e9f172cf6ec6/image1.jpeg

Perfmon captures data from parameters set in data collector sets which control things like the log directory, log schedules, and any stop conditions. It is these data collector sets or groups of parameters that define what to log and when is how you can save time with templates.

Templates, stored as XML, allow you to capture all of the parameters needed to query performance counters and to create data collections. Once you have that template, you can then easily transfer that data collector set to other machines.

Templates can be created from existing data collector sets and can be imported. These tasks are what you're primarily going to learn in this article.

Prerequisites

If you'd like to follow along with this tutorial, please be sure you have the following prerequisites in place.

  • Windows Server - We'll be using Windows Server 2019 in this article
  • 7-zip to unzip some sample templates

Creating Performance Monitor Templates

Before you can leverage performance monitor templates, you must first create them. Creating a template consists of creating a data collector set as usual and then saving the settings as a template. The process is surprisingly simple.

To create a perfmon template, on your Windows Server machine:

  1. Open up Windows Performance Monitor (perfmon) via perfmon.msc or by opening up via the start menu.
  2. In the left pane, expand Data Collector Sets and click on User Defined. This allows you to customize the kind of data you'll be collecting.
  3. Right-click on User Defined and click New —> Data Collector Set to open the Create New Data Collector Set window as shown below. Type a Name for your data collector set, click Create manually (Advanced), and click Next. Note the Create from a template (Recommended) option. This is the same place you'll go when importing a template later.
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b3f66c69-3fd3-49d9-bb7f-f5797c161f04/Untitled.png

4.  In the next screen, you'll be prompted to select what kind of data you'd like to collect as shown below. These options are up to you. Once you do this, click on Finish and your data collector set will be stored directly under User Defined as you'll see in the upcoming screenshot.

Depending on which boxes you clicked, you will be prompted to specify the parameters for Performance counter, Event trace data, and System configuration information. That is a deep dive for another tutorial.
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/55d39aa6-2581-4cb8-84f8-87316cccc232/Untitled.png

5.  As shown below, right-click on the data collector set just created and click Save Template. You will then be prompted where to save the XML file to.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/3cccae4c-2918-40e9-bb82-60ed44638153/image2.png

That's it! That's all there is to creating a performance monitoring template. At this point, you can follow the same steps you'll be learning about in the next section to create a data collector set from this template.

Creating a Data Collector Set from a Template

Sometimes it's just faster to start with someone else's vast and learned accomplishments. Smugness aside, let's download and use a pre-existing template. The template you'll be using is a base operating system capture. It does not include any performance counter references to applications like Microsoft Exchange or SQL, for example.

When creating a data collector set from template, be sure the computer the data collector set is being created on has the same performance counters as the source computer.

To import the example XML Template into perfmon:

  1. Go to the GitHub repository, download the performance_capture - rolling 200.7z file and extract it's contents.
  2. On Windows Server, open up perfmon, right-click on User Defined and click New —> Data Collector Set to open the Create New Data Collector Set window as shown below. Type the Name for the data collector set and ensure Create from a template (Recommended) is selected and click Next.
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/acead939-3747-449d-89f6-df6ce2234145/Untitled.png

3.  The template data collector set in this template example is a Basic one. Choose Basic and click Next. Then click Browse to open the browse window and pick the performance_capture - rolling 200.xml file extracted from the ZIP file earlier.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/721b55bd-79b7-4e40-b508-d67a8734a7f4/Untitled.png

Once the XML template has been selected, perfmon will read the template and provide the template data collector set it found along with any notes in the template as shown below. Click Next.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e3334498-0979-4aea-99f7-20718e07a974/Untitled.png

4.  Select a place to save the logs generated from this data collector set. You can see below the default path has been selected for you. This path is in the XML template. Leave the default file location as-is and click Next.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a87a61ea-a1bd-4b0d-82ae-555c54f70650/Untitled.png

5.  Ensure Save and close is selected and click Finish.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c3383562-e108-4c69-bf33-9a8b432f8e57/Untitled.png

You have now created a data collector set from an XML template.

Starting the Data Collector Set

The data collector set is now built from the XML template but it's not doing much at the moment. You have to start the data collector set. To do so:

  1. Open perfmon if it's not already open.
  2. In the left pane, expand Data Collector Sets —> User Defined. You should now see the data collector set you just created from the template.
  3. Right-click your custom data collector set and click Start from the pop-up menu as shown below. Performance counters will now begin collecting data.
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9830570d-a31a-4c8f-8462-79b1afc0fb3f/Untitled.png

Reviewing the Created Data Collector Set

Once the data collector set has been created via XML template, you can now inspect the settings to ensure perfmon imported all expected settings.

From permon:

  1. Expand Data Collector Sets —> User Defined in the left pane.
  2. Right-click the custom data collector set just created and click Properties from the pop-up menu to open the Properties dialog box as you can see below.
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/1830a926-919f-4550-a444-1d1b002e7d1e/Untitled.png

3.  Click the Schedule tab. In this tab, verify the Start date is in the past and the checkbox for All schedules enabled is checked. This will make sure your server will resume logging data in the event of a reboot/crash.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c1d93c68-16c8-441f-96c6-f13d3a36a7eb/Untitled.png

4.  Click the Stop Condition tab. Here, verify the Maximum Size of the output file is 200MB as well as the Maximum Size checkbox is checked. Anything larger than 200MB becomes unwieldy.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/575867a4-2781-400f-8cac-1ea87bd32867/Untitled.png

5.  Click OK to close the Properties dialog box.

Reviewing the Data Collector

The XML template creates a data collector set but inside of that set are individual data collectors. You should also inspect the data collector created by the template. To do that:

  1. Select the data collector in the middle pane, right-click, and click Properties from the pop-up menu as shown below.
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/45b41382-a1d8-4b2d-956b-b0584cc53886/Untitled.png

2.  In the Performance Counter Properties dialog box, ensure the Performance Counters tab is selected as shown below.

For this exercise, we are just taking a peek. Note the Performance counters being collected. In the future you can add or remove them to suit your needs. Also note the Log format is binary (BLG). Unlike tab or comma-separated value file output, BLG has a dynamic schema. This is helpful if a process starts after the log starts, it will still be included in the log file. Also notice the sample rate on this tab.
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/613c8532-b52f-469c-a211-2dd84d8c92b4/Untitled.png

3.  Click the File tab. In this box, the Log mode should be Circular. This mode captures the last several hours of the systems' activity and is written in a first-in, first-out method.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e7273cde-95fc-4115-b1ba-efd0803c5b50/Untitled.png

4.  Click OK to close the Properties dialog box and you're done!

Wrapping it up

Using performance monitoring templates to create data collector sets is a convenient way to manage performance counters at scale or via automation. You've now seen an example of using templates. Armed with that knowledge, how do you plan to use templates in your day-to-day tasks?