Skip to main content

Windows Exporter

Introduction

Windows Exporter (formerly known as WMI Exporter) is a Prometheus exporter for Windows machines. It collects metrics from Windows systems using Windows Management Instrumentation (WMI) and Windows Performance Counters, making them available for Prometheus to scrape. This tool is essential for monitoring Windows-based infrastructure in environments where Prometheus is used as the monitoring solution.

In this guide, we'll explore how Windows Exporter works, how to install and configure it, and how to use it effectively to monitor Windows systems with Prometheus.

What is Windows Exporter?

Windows Exporter is an open-source tool that exposes Windows system metrics in a format that Prometheus can understand. It acts as a bridge between Windows-specific monitoring interfaces and the Prometheus ecosystem.

Key features of Windows Exporter include:

  • Collection of various Windows metrics (CPU, memory, disk, network, etc.)
  • Modular design with collectors that can be enabled or disabled
  • Ability to expose Windows Performance Counter metrics
  • Support for both 32-bit and 64-bit Windows systems
  • Easy integration with existing Prometheus setups

Installation

Prerequisites

  • A Windows machine (Windows 7 or newer, Windows Server 2008 R2 or newer)
  • Administrative privileges
  • Prometheus server (for scraping the metrics)

Download and Install

  1. Visit the Windows Exporter releases page on GitHub
  2. Download the appropriate MSI installer for your Windows version (32-bit or 64-bit)
  3. Run the installer with administrative privileges

The basic installation can be done using the GUI installer or through the command line:

powershell
# Install windows_exporter with default collectors
msiexec /i windows_exporter-0.20.0-amd64.msi

# Install with specific collectors enabled
msiexec /i windows_exporter-0.20.0-amd64.msi COLLECTORS="cpu,memory,disk,net"

After installation, Windows Exporter runs as a Windows service and listens on port 9182 by default.

Configuration

Basic Configuration

Windows Exporter comes with a default configuration that enables several essential collectors. You can customize which collectors are enabled during installation or by modifying the service parameters.

The configuration is done through command-line flags that can be set as parameters during installation or by editing the service configuration:

powershell
# View current collectors
windows_exporter --collectors.print

# Configure service with specific collectors
sc.exe config windows_exporter start= auto obj= LocalSystem binpath= "C:\Program Files\windows_exporter\windows_exporter.exe --collectors.enabled=cpu,memory,disk,net"

Available Collectors

Windows Exporter provides numerous collectors for different aspects of a Windows system. Some of the most commonly used collectors include:

CollectorDescription
cpuCPU usage metrics
memoryMemory usage metrics
diskDisk space and IO metrics
netNetwork interface metrics
serviceWindows service state metrics
osOperating system information
systemSystem-wide statistics
logonLogon session metrics
processProcess metrics (memory, CPU)
iisInternet Information Services metrics
mssqlMicrosoft SQL Server metrics
exchangeMicrosoft Exchange Server metrics

For a complete list of collectors and their descriptions, refer to the Windows Exporter documentation.

Windows Exporter Metrics

Metric Types

Windows Exporter exposes various metrics that follow the Prometheus convention:

  • Counters: Metrics that increase over time (e.g., bytes sent on a network interface)
  • Gauges: Metrics that can go up and down (e.g., memory usage)
  • Histograms: Distribution of values (e.g., request duration)

Example Metrics

Here are some example metrics exposed by Windows Exporter:

# HELP windows_cpu_time_total Total CPU time
# TYPE windows_cpu_time_total counter
windows_cpu_time_total{core="0",mode="idle"} 2345.125
windows_cpu_time_total{core="0",mode="interrupt"} 10.578
windows_cpu_time_total{core="0",mode="user"} 538.109
windows_cpu_time_total{core="0",mode="system"} 157.906

# HELP windows_logical_disk_free_bytes Free space in bytes
# TYPE windows_logical_disk_free_bytes gauge
windows_logical_disk_free_bytes{volume="C:"} 107374182400
windows_logical_disk_free_bytes{volume="D:"} 214748364800

# HELP windows_memory_available_bytes Amount of physical memory available in bytes
# TYPE windows_memory_available_bytes gauge
windows_memory_available_bytes 4294967296

Integrating with Prometheus

Prometheus Configuration

To scrape metrics from Windows Exporter, add a job to your Prometheus configuration file (prometheus.yml):

yaml
scrape_configs:
- job_name: 'windows'
static_configs:
- targets: ['windows-host:9182']
relabel_configs:
- source_labels: [__address__]
target_label: instance
regex: '(.*):.+'
replacement: '${1}'

If you have multiple Windows hosts, you can use service discovery mechanisms like DNS or file-based discovery:

yaml
scrape_configs:
- job_name: 'windows'
file_sd_configs:
- files:
- 'windows_targets.json'

With windows_targets.json containing:

json
[
{
"targets": ["windows-server1:9182", "windows-server2:9182"],
"labels": {
"env": "production"
}
}
]

Verifying Scraping

After configuring Prometheus, you can verify that it's correctly scraping Windows Exporter metrics:

  1. Open the Prometheus web interface (usually at http://prometheus-server:9090)
  2. Go to the "Status" > "Targets" page
  3. Look for the Windows Exporter targets and ensure they show as "UP"
  4. Try querying some Windows metrics in the "Graph" section, such as windows_cpu_time_total

Practical Examples

Monitoring CPU Usage

To monitor CPU usage across your Windows machines:

rate(windows_cpu_time_total{mode="user"}[5m]) * 100

This query calculates the 5-minute average CPU utilization percentage in user mode.

Disk Space Monitoring

To monitor free disk space and alert when it falls below a threshold:

100 * windows_logical_disk_free_bytes / windows_logical_disk_size_bytes < 10

This query will return true for disks with less than 10% free space.

Memory Usage Dashboard

Here's a PromQL query for a Grafana dashboard showing memory usage:

windows_memory_available_bytes / windows_os_physical_memory_free_bytes * 100

Service Monitoring

To monitor Windows services and their states:

windows_service_state{state="running", name="wuauserv"}

This query returns 1 if the Windows Update service is running, and 0 otherwise.

Building Dashboards

Windows Exporter metrics can be visualized in tools like Grafana. Here's a basic architecture for a monitoring dashboard:

You can create comprehensive dashboards for your Windows infrastructure. Some key panels to include:

  • CPU usage by mode
  • Memory utilization and available memory
  • Disk space and I/O operations
  • Network traffic by interface
  • Service status for critical services
  • Event log counts by severity

Troubleshooting

Common Issues

  1. Windows Exporter not starting

    • Check Windows Services console to see any errors
    • Verify log files in the Windows Event Viewer
  2. Metrics not appearing in Prometheus

    • Ensure the Windows firewall allows connections on port 9182
    • Verify Prometheus configuration is correct
    • Check the target status in Prometheus UI
  3. High resource usage by the exporter

    • Disable unused collectors to reduce resource consumption
    • Increase scrape interval in Prometheus configuration

Debugging

You can access metrics directly from the Windows Exporter endpoint for debugging:

http://windows-host:9182/metrics

This returns all the raw metrics which can be useful for troubleshooting.

Advanced Configuration

Using Custom Performance Counters

Windows Exporter allows collecting custom performance counters using the perf collector:

powershell
msiexec /i windows_exporter-0.20.0-amd64.msi COLLECTORS="perf" EXTRA_FLAGS="--collector.perf.classes=".NET CLR Memory","ASP.NET Applications""

High-Security Environments

In environments with strict security requirements, you might need to:

  1. Configure TLS for encrypted metric transmission
  2. Set up authentication for the exporter
  3. Restrict collector capabilities to minimize access rights

Example configuration with TLS:

powershell
windows_exporter.exe --web.config.file=web-config.yml

With web-config.yml containing:

yaml
tls_server_config:
cert_file: server-cert.pem
key_file: server-key.pem
basic_auth_users:
prometheus: $2y$10$GCq0McqQlJ.T3UNpFQzm0Oz3N.xnbGc0QwtQAZFBCDHUBBFMM0qzq

Summary

Windows Exporter provides a powerful way to monitor Windows systems using Prometheus. By collecting system metrics and exposing them in Prometheus format, it allows you to:

  • Monitor Windows servers alongside your Linux and containerized workloads
  • Create unified dashboards across heterogeneous environments
  • Set up alerting based on Windows system metrics
  • Track performance trends over time

With proper configuration and integration into your monitoring stack, Windows Exporter becomes an invaluable tool for maintaining Windows infrastructure health and performance.

Additional Resources

Exercises

  1. Install Windows Exporter on a test system and configure Prometheus to scrape its metrics.
  2. Create a basic Grafana dashboard showing CPU, memory, and disk usage for a Windows server.
  3. Set up alerting rules in Prometheus to notify when disk space is running low or critical services stop.
  4. Experiment with different collectors and determine which ones are most relevant for your environment.
  5. Create a custom dashboard for monitoring IIS or SQL Server performance using specialized collectors.


If you spot any mistakes on this website, please let me know at [email protected]. I’d greatly appreciate your feedback! :)