WMI Adapter

Last Updated On November 24, 2018
You are here:


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


This adapter can be configured in two ways: legacy using Server element and just connection string. To configure adapter, modify Sonar configuration file as follows:

<?xml version="1.0"?>
<section name="Sonar" type="Infragravity.Sonar.SonarConfigurationSection, Sonar"/>
<add name="local" providerName="wsman" connectionString="Server=sonar;" />
<add name="influxdb-udp" providerName="output-influxdb-udp" connectionString="Data Source = udp://host:8092;Initial Catalog=sonar;User Id =; Password =; Application Name = default;Max Pool Size=100;Packet Size=1200;Connection Timeout=10;Flush Timeout=10;"/>
<Runtime scrapeIntervalSeconds="5" skipSSLCheck="true" threads="1"/>
<add provider="wsman" type="Infragravity.Sonar.Adapters.WsMan.WsmanAdapterFactory,Sonar" />
<add provider="output-influxdb-udp" type="Infragravity.Sonar.Adapters.InfluxDb.Udp.OutputAdapterFactory,Infragravity.Sonar.Adapters.InfluxDb" />
<add name="btswin_evlog" array="mslog-basic.sonar.config" input="local" intervalSeconds="15" output="influxdb-udp" />
<add name="sonar" url="http://localhost:5985/wsman" username="" password="" timeoutMilliseconds="1000" authType="Negotiate"/>

Configuring WinRM

The access to WS-Management endpoint can be enabled using HTTPS or HTTP protocols. Sonar monitoring agent can gather metrics via WS-Management protocol locally or remotely. For development on Windows container, virtual machine or host, execute the following commands from PowerShell:

winrm quickconfig


To allow access to WinRM listener via HTTP, execute the following command from PowerShell and modify Sonar.config:

winrm set winrm/config/service @{AllowUnencrypted="true"}
<add name="local" providerName="wsman" connectionString="Server=sonar;" />
<add name="sonar" url="http://localhost:5985/wsman" username="" password="" timeoutMilliseconds="1000" authType="Negotiate"/>


To allow access via HTTPS, create X509 certificate and configure WinRM listener for using it:

Get-ChildItem -path cert:\LocalMachine\My\
winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="<hostname>";CertificateThumbprint="<thumbprint>"}
<add name="local" providerName="wsman" connectionString="Server=sonar;" />
<add name="sonar" url="https://localhost:5986/wsman" username="" password="" timeoutMilliseconds="1000" authType="Negotiate"/>

Note that using Negotiate authentication will require Sonar process running under credentials with sufficient permissions to access WinRM listener. For remote access from Sonar deployed on Linux container, VM or host without  integration with Active Directory, Basic authentication can be used by modifying Sonar.config as follows:   

<add name="sonar" url="http://localhost:5985/wsman" username="myuser" password="mypassword" timeoutMilliseconds="1000" authType="Basic"/>

To enable Basic authentication for WinRM, execute following command from console or PowerShell on Windows:

winrm set winrm/config/service/auth @{Basic="true"}