Share via

How to: Create Performance Counter Categories

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

You can create a new category to contain custom counters. For example, if you plan to create a series of counters to track various data about the orders processed on a Web site, you might create a category called OrderData on your server and then create the counters you need in it.

Creating a category is not a distinct process from creating the counters that are included in it; counters can only be created at the point when you create the category itself. You cannot create categories and counters on, or remove them from, remote computers.

There are several ways you can create counters and categories:

To create a category and a single counter in it

  • Call the Create method on the PerformanceCounterCategory class and specify the following parameters:




    Any category name that is not already being used on this server.


    A description of the category.


    A name for the counter.


    A description of the counter. This text is displayed in Windows Performance Monitor when a user selects a counter and clicks the Explain button.

    The following example shows how you might create a simple category with the Create method:

    Sub CreateCustomCounter()
        PerformanceCounterCategory.Create("CategoryName", "CounterHelp",
            "CounterName", "CounterHelp")
    End Sub
        void CreateCustomCounter()
            PerformanceCounterCategory.Create("CategoryName", "CounterHelp",
                "CounterName", "CounterHelp");


By default, the counters created with this code will be read-write enabled, but your interaction with them by way of a PerformanceCounter component instance will be read-only unless you specify otherwise. You can change the value of the ReadOnly property for a component instance to false if you want to modify a counter.

See Also


How to: Create Custom Performance Counters


Category and Counter Management