Performance Counters Adapter

Last Updated On October 15, 2018
You are here:

Overview

This adapter collects values of Windows performance counters when enabled in Sonar monitoring agent for following scenarios with Windows OS version 2008 R2 or above:

  • Servers
  • Windows containers with Hyper-v or process isolation
  • Virtual machines

Configuration

To configure adapter, modify Sonar configuration file as follows:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="Sonar" type="Infragravity.Sonar.SonarConfigurationSection, Sonar"/>
  </configSections>
  <connectionStrings>
    <add name="perfmon" providerName="mspdh" connectionString="." />
  </connectionStrings>
  <Sonar>
    <Runtime scrapeIntervalSeconds="5" skipSSLCheck="true" threads="1"/>
    <InputAdapters>
      <add provider="mspdh" type="Infragravity.Sonar.Adapters.PerformanceCounter.PerfCounterAdapterFactory,Infragravity.Sonar.Adapters.PerformanceCounter" />
    </InputAdapters>
    <OutputAdapters>
    </OutputAdapters>
    <Arrays>
      <add name="btswin_local" array="mswin-basic.sonar.config" input="perfmon" intervalSeconds="2" output="akumulidb-udp"/>
    </Arrays>
    <Schedules/>
    <Servers/>
    <Queries/>
  </Sonar>
 </configuration>

In the above example, all queries defined in the mswin-basic configuration file will be used to gather telemetry and expose it to Prometheus every 2 seconds.

Queries

The example queries are shown below:

<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="Sonar" type="Infragravity.Sonar.SonarConfigurationSection, Sonar"/>
    </configSections>
    <Sonar>
        <Schedules/>
        <Servers/>
        <Queries>
            <add name="Perfmon_WebService" type="raw" filter="*" resource="." namespace="Web Service">
                <Tags>
                    <add name="name" value="name"/>
                </Tags>
                <Values>
                    <add name="total_put_requests" value="Total Put Requests"/>
                    <add name="total_get_requests" value="Total Get Requests"/>
                    <add name="total_post_requests" value="Total Post Requests"/>
                </Values>
            </add>
            <add name="Perfmon_ProcessorInformation" type="raw" filter="*" resource="." namespace="Processor Information">
                <Tags>
                    <add name="name" value="name"/>
                </Tags>
                <Values>
                    <add name="percent_processor_time" value="% Processor Time"/>
                    <add name="percent_user_time" value="% User Time"/>
                </Values>
            </add>
            <add name="Perfmon_LogicalDisk" type="raw" filter="*" resource="." namespace="LogicalDisk">
                <Tags>
                    <add name="name" value="name"/>
                </Tags>
                <Values>
                    <add name="avgbytes_read" value="Avg. Disk Bytes/Read"/>
                    <add name="avgbytes_write" value="Avg. Disk Bytes/Write" />
                </Values>
        </Queries>
    </Sonar>
</configuration>

As you can see from the above examples, the value of namespace and filter attributes to define performance counter name. The resource attribute value “.” indicates local machine name. For example, Perfmon_LogicalDisk query gathers data from two counters: “.\LogicalDisk(*)\Avg. Disk Bytes/Read” and “.\LogicalDisk(*)\Avg. Disk Bytes/Write” respectively for all logical disks.

Limitations

  • Gathering values from Windows performance counters on remote host is not supported.