Question

I have serious problems to get running Custom Performance Counters in the Windows Azure. I’m creating Performance Counters via aspect implemented with the help of PostSharp, dynamically, upon the configuration changes in *.cscfg file. The Performance Counters are created correctly, in the emulator and also in the Azure Environment (checked via Remote Desktop) as I can see the Performance Counter instances in the Computer Management Console under the Performance Tools -> Monitoring Tools -> Performance Monitor. I added the Performance Counter in the diagnostics.wadcfg.

<?xml version="1.0" encoding="utf-8"?>
<DiagnosticMonitorConfiguration configurationChangePollInterval="PT1M" overallQuotaInMB="4096" xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
  <DiagnosticInfrastructureLogs />
  <Directories>
    <IISLogs container="wad-iis-logfiles" />
    <CrashDumps container="wad-crash-dumps" />
  </Directories>
  <Logs bufferQuotaInMB="1024" scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Information" />
  <PerformanceCounters bufferQuotaInMB="250" scheduledTransferPeriod="PT1M">
    <PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT1S" />
    <PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT1S" />
    <PerformanceCounterConfiguration counterSpecifier="\_Customer Category\average execution time for member call" sampleRate="PT1S" />
  </PerformanceCounters>
  <WindowsEventLog bufferQuotaInMB="1024" scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Error">
    <DataSource name="Application!*" />
  </WindowsEventLog>
</DiagnosticMonitorConfiguration>

The problem is that I never see the Performance Counter values in the WADPerformanceCountersTable. If I start the emulator I see this error:

[MonAgentHost] Error: MA EVENT: 2013-09-05T15:30:49.373Z
[MonAgentHost] Error:     2
[MonAgentHost] Error:     8360
[MonAgentHost] Error:     12556
[MonAgentHost] Error:     SysCounterListener.dll
[MonAgentHost] Error:     0
[MonAgentHost] Error:     5fd713ae-0085-4ba3-87f6-e21ad86
[MonAgentHost] Error:     liscounter.cpp
[MonAgentHost] Error:     SystemCounter::AddCounter
[MonAgentHost] Error:     660
[MonAgentHost] Error:     ffffffffc0000bb8
[MonAgentHost] Error:     0
[MonAgentHost] Error:     
[MonAgentHost] Error:     PdhAddCounter(\_Customer Category\average execution time for member call) failed

Code to create category see below (_categoryName = "_Custom Category" and _counterName = "average execution time for member call")

    private void CreateCategory()
    {
        if (!PerformanceCounterCategory.Exists(_categoryName))
        {
            Trace.TraceInformation("Creating new category '{0}'", _categoryName);

            _counters = new CounterCreationDataCollection
            {
                new CounterCreationData(_counterName, _performanceCounterHelperText, PerformanceCounterType.AverageTimer32),
                new CounterCreationData(_averageBasePerformanceCounterName, string.Empty, PerformanceCounterType.AverageBase)
            };

            PerformanceCounterCategory.Create(_categoryName, string.Empty, PerformanceCounterCategoryType.MultiInstance, _counters);
        }
    }

    private void CreateOrGetPerformanceCounters()
    {
        string averageBasePerformanceCounterName = string.Format("{0} {1}", _counterName, "base");

        Trace.TraceInformation("Get new instance '{0}' of counter '{1}' in the category '{2}'", _instanceName, _counterName, _categoryName);
        _performanceCounterAverage = new PerformanceCounter(
            _categoryName, _counterName, _instanceName, false);

        _performanceCounterAverageBase = new PerformanceCounter(
            _categoryName, averageBasePerformanceCounterName, _instanceName, false);
    }

The next question is, how can I get the concrete instance of the performance counter? In the Management Console I can choose which instance should be showed, how can I do this in the Azure?

Was it helpful?

Solution

There were two mistakes

  1. Typo in the diagnostics.wadcfg file: The category name is _Custom Category and I wrote CustomER Category
  2. The format for the Performace Counter is: \[Category Name]([Instance Name]|*)\[Performance Counter Name], so in my case is it \_Custom Category(*)\average execution time for member call. In this case was asterix missing!
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top