Saving Time with Windows PerfMon Templates
Tags: windows
Published: 2021-01-15 20:20:48

> _This article was written by Jeff Stokes. He is a frequent contributor to the Adam the Automator (ATA) blog. If you'd like to read more from this author, check out his [ATA author page](http://adamtheautomator.com/author/jeff-stokes). Be sure to also check out [more how-to posts on cloud computing, system administration, IT, and DevOps on adamtheautomator.com](https://adamtheautomator.com)!_

<!-- wp:paragraph -->
<p>Do you rely on <a href="https://techcommunity.microsoft.com/t5/Ask-The-Performance-Team/Windows-Performance-Monitor-Overview/ba-p/375481">Windows Performance Monitor</a> to discover the root cause of Windows performance monitoring issues? Are you still struggling with creating lots of performance monitors at once or simply need a way to automate the process? If so, in this article, you're going to learn how to create perfmon templates and data collector set templates!</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In this article, you’ll learn how to do Windows Performance Monitoring by building XML performance monitoring templates to save yourself valuable time.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="how-templates-work-in-windows-performance-monitoring">How Templates Work in <strong>Windows Performance Monitoring</strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Windows Performance Monitor (<em>perfmon</em>) is a native <a href="https://adamtheautomator.com/new-windows-terminal/">Windows</a> tool for administrators to specify attributes like performance counters, event tracing for Windows events, and system configuration items. Once the attributes are set, <em>perfmon</em> captures data into one of several formats: binary log, SQL, Data Source Name (DSN), or CSV.</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p><em>Only capture the data you need via performance monitoring. If not, you risk negatively affecting the performance of your servers!</em></p></blockquote>
<!-- /wp:quote -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/orjtt37idkpsvbhd6xu1.jpeg)

<!-- wp:paragraph -->
<p>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.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>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.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>You can create perfmon templates from existing data collector sets and can be imported. These tasks are what you're primarily going to learn in this article.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="prerequisites">Prerequisites</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>If you'd like to follow along with this tutorial, please be sure you have the following prerequisites in place.</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Windows Server - We'll be using Windows Server 2019 in this article</li><li><a href="https://www.7-zip.org/">7-zip</a> to unzip some sample templates</li></ul>
<!-- /wp:list -->

<!-- wp:heading -->
<h2 id="creating-performance-monitor-templates">Creating PerfMon Templates</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Before you can leverage performance monitor templates for Windows performance monitoring, 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.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>To create a perfmon template, on your Windows Server machine:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Open up <em>Windows Performance Monitor (perfmon)</em> via <em>perfmon.msc</em> or by opening up via the start menu.</li><li>In the left pane, expand <strong>Data Collector Sets</strong> and click on <strong>User Defined</strong>. This allows you to customize the kind of data you'll be collecting.</li><li>Right-click on <strong>User Defined</strong> and click <strong>New</strong> —&gt; <strong>Data Collector Set</strong> to open the <strong>Create New Data Collector Set</strong> window as shown below. Type a <strong>Name</strong> for your data collector set, click <strong>Create manually (Advanced)</strong>, and click <strong>Next</strong>. Note the <strong>Create from a template (Recommended)</strong> option. This is the same place you'll go when importing a template later.</li></ol>
<!-- /wp:list -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/d5as0fpzwwpijq3vhtit.png)

<!-- wp:paragraph -->
<p>4. &nbsp;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 <strong>Finish</strong> and your data collector set will be stored directly under <strong>User Defined</strong> as you'll see in the upcoming screenshot.</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p><em>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.</em></p></blockquote>
<!-- /wp:quote -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8qdn0qos77dacunrut59.png)
<!-- wp:paragraph -->
<p>5. &nbsp;As shown below, right-click on the data collector set just created and click <strong>Save Template</strong>. You will then be prompted where to save the XML file to.</p>
<!-- /wp:paragraph -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ke8pojr59xh6jveyn7ag.png)

<!-- wp:paragraph -->
<p>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.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="creating-a-data-collector-set-from-a-template">Creating a Perfmon Data Collector Set Template</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Sometimes it's just faster to start with someone else's vast and learned accomplishments when it comes to Windows performance monitoring. 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.</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p><em>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.</em></p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>To import the example XML Template into <em>perfmon</em>:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Go to the <a href="https://github.com/jeffstokes72/Perf-Templates">GitHub repository</a>, download the <em>performance_capture - rolling 200.7z</em> file and extract it's contents.</li><li>On Windows Server, open up <em>perfmon</em>, right-click on <strong>User Defined</strong> and click <strong>New</strong> —&gt; <strong>Data Collector Set</strong> to open the <strong>Create New Data Collector Set</strong> window as shown below. Type the <strong>Name</strong> for the data collector set and ensure <strong>Create from a template (Recommended)</strong> is selected and click <strong>Next</strong>.</li></ol>
<!-- /wp:list -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vyo253t0dfc15645nuui.png)

<!-- wp:paragraph -->
<p>3. &nbsp;The template data collector set in this template example is a Basic one. Choose <strong>Basic</strong> and click <strong>Next</strong>. Then click <strong>Browse</strong> to open the browse window and pick the <em>performance_capture - rolling 200.xml</em> file extracted from the ZIP file earlier.</p>
<!-- /wp:paragraph -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hy5wdyotyn6502ixi02a.png)

<!-- wp:paragraph -->
<p>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 <strong>Next</strong>.</p>
<!-- /wp:paragraph -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lcbky8esu5z1rjvdbkdf.png)

<!-- wp:paragraph -->
<p>4. &nbsp;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 <strong>Next</strong>.</p>
<!-- /wp:paragraph -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/btjuv4bxtai1fjjhr390.png)

<!-- wp:paragraph -->
<p>5. &nbsp;Ensure <strong>Save and close</strong> is selected and click <strong>Finish</strong>.</p>
<!-- /wp:paragraph -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ogsbcafufz11fuj8nmrl.png)
<!-- wp:paragraph -->
<p>You have now created a data collector set from an XML template.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="starting-the-data-collector-set">Starting the Data Collector Set</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Open <em>perfmon</em> if it's not already open.</li><li>In the left pane, expand <strong>Data Collector Sets</strong> —&gt; <strong>User Defined</strong>. You should now see the data collector set you just created from the template.</li><li>Right-click your custom data collector set and click <strong>Start</strong> from the pop-up menu as shown below. Performance counters will now begin collecting data.</li></ol>
<!-- /wp:list -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tw742abb88o71s6zonmd.png)

<!-- wp:heading -->
<h2 id="reviewing-the-created-data-collector-set">Reviewing the Created Data Collector Set</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Once the data collector set has been created via XML template, you can now inspect the settings to ensure <em>perfmon</em> imported all expected settings.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>From <em>permon</em>:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Expand <strong>Data Collector Sets</strong> —&gt; <strong>User Defined</strong> in the left pane.</li><li>Right-click the custom data collector set just created and click <strong>Properties</strong> from the pop-up menu to open the <strong>Properties</strong> dialog box as you can see below.</li></ol>
<!-- /wp:list -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/m7cpp65y4hklud25lg37.png)

<!-- wp:paragraph -->
<p>3. &nbsp;Click the Schedule tab. In this tab, verify the <strong>Start</strong> date is in the past and the checkbox for <strong>All schedules enabled</strong> is checked. This will make sure your server will resume logging data in the event of a reboot/crash.</p>
<!-- /wp:paragraph -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/h7dpx89yih69wi6k4is7.png)

<!-- wp:paragraph -->
<p>4. &nbsp;Click the Stop Condition tab. Here, verify the <strong>Maximum Size</strong> of the output file is 200MB as well as the <strong>Maximum Size</strong> checkbox is checked. Anything larger than 200MB becomes unwieldy.</p>
<!-- /wp:paragraph -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/s6op0vof6gj5btfnfq9v.png)

<!-- wp:paragraph -->
<p>5. &nbsp;Click OK to close the <strong>Properties</strong> dialog box.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="reviewing-the-data-collector">Reviewing the Data Collector</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Select the data collector in the middle pane, right-click, and click <strong>Properties</strong> from the pop-up menu as shown below.</li></ol>
<!-- /wp:list -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ew7gasp8lzrdlbjgos8g.png)

<!-- wp:paragraph -->
<p>2. &nbsp;In the <strong>Performance Counter Properties</strong> dialog box, ensure the <strong>Performance Counters</strong> tab is selected as shown below.</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p><em>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.</em></p></blockquote>
<!-- /wp:quote -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/z67vt0eh4cnupr57opd3.png)

<!-- wp:paragraph -->
<p>3. &nbsp;Click the <strong>File</strong> tab. In this box, the <strong>Log mode</strong> should be Circular. This mode captures the last several hours of the systems' activity and is written in a first-in, first-out method.</p>
<!-- /wp:paragraph -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xpmh6dlfnn77x462l0fs.png)

<!-- wp:paragraph -->
<p>4. &nbsp;Click <strong>OK</strong> to close the Properties dialog box and you're done!</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="wrapping-it-up">Wrapping up Perfmon Templates</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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?</p>
<!-- /wp:paragraph -->