How to Monitor Windows Server with Prometheus and Grafana on Windows Server 2016

Prometheus and Grafana form a powerful open-source monitoring stack widely used in both Linux and Windows environments. Prometheus is a time-series metrics database that scrapes exporters at regular intervals. Grafana is a visualization platform that queries Prometheus and renders dashboards. On Windows Server 2016, the windows_exporter (formerly wmi_exporter) exposes hundreds of Windows performance counters, service states, and IIS metrics to Prometheus in a format it can scrape.

This guide covers installing windows_exporter on Windows Server 2016, setting up a Prometheus server (on Linux or Windows), and building a Grafana dashboard for the server.

Step 1: Install windows_exporter on Windows Server 2016

Download the latest windows_exporter MSI from the GitHub releases page at github.com/prometheus-community/windows_exporter/releases. Run the installer as Administrator. The exporter installs as a Windows service named windows_exporter and listens on port 9182 by default.

To install with specific collectors enabled:

msiexec /i windows_exporter-0.27.0-amd64.msi ENABLED_COLLECTORS="cpu,memory,net,logical_disk,system,service,os,iis,tcp" /quiet

Verify the service is running:

Get-Service windows_exporter

Test the metrics endpoint locally:

Invoke-WebRequest -Uri http://localhost:9182/metrics -UseBasicParsing | Select-Object -ExpandProperty Content | Select-Object -First 50

Step 2: Open Firewall Port 9182

Allow Prometheus to reach the exporter by opening inbound TCP 9182 on the Windows Server firewall:

New-NetFirewallRule -DisplayName "windows_exporter" -Direction Inbound -Protocol TCP -LocalPort 9182 -Action Allow

Step 3: Install Prometheus on a Monitoring Server

Prometheus is typically deployed on a dedicated Linux monitoring server. Download Prometheus from prometheus.io/download and extract it:

wget https://github.com/prometheus/prometheus/releases/download/v2.52.0/prometheus-2.52.0.linux-amd64.tar.gz
tar xvfz prometheus-2.52.0.linux-amd64.tar.gz
cd prometheus-2.52.0.linux-amd64

Create or edit prometheus.yml to add the Windows Server target:

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'windows_server_2016'
    static_configs:
      - targets: ['192.168.1.50:9182']
        labels:
          instance: 'WS2016-01'
          environment: 'production'

Start Prometheus:

./prometheus --config.file=prometheus.yml --storage.tsdb.retention.time=30d

Step 4: Install Prometheus as a systemd Service (Linux)

sudo useradd --no-create-home --shell /bin/false prometheus
sudo cp prometheus /usr/local/bin/
sudo cp promtool /usr/local/bin/

cat <<EOF | sudo tee /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
After=network.target

[Service]
User=prometheus
ExecStart=/usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --storage.tsdb.retention.time=30d
Restart=always

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now prometheus

Step 5: Install Grafana

Install Grafana on the same monitoring server or a separate one. For Debian/Ubuntu-based systems:

sudo apt-get install -y apt-transport-https software-properties-common
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt-get update && sudo apt-get install grafana
sudo systemctl enable --now grafana-server

Step 6: Add Prometheus as a Grafana Data Source

Open Grafana at http://monitoring-server:3000 and log in with admin/admin (change on first login). Navigate to Configuration > Data Sources > Add data source. Select Prometheus, enter the URL http://localhost:9090, and click Save and Test.

Step 7: Import a Windows Exporter Dashboard

Navigate to Dashboards > Import. Enter dashboard ID 14694 (Windows Node dashboard from Grafana.com) and click Load. Select your Prometheus data source and click Import. The dashboard renders panels for CPU, memory, disk, and network using metrics from windows_exporter.

Step 8: Create Custom Alerting Rules

Add alerting rules to prometheus.yml to trigger alerts on high CPU or low disk space:

groups:
  - name: windows_alerts
    rules:
      - alert: HighCPUUsage
        expr: 100 - (avg by(instance) (rate(windows_cpu_time_total{mode="idle"}[5m])) * 100) > 90
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "High CPU on {{ $labels.instance }}"

      - alert: LowDiskSpace
        expr: (windows_logical_disk_free_bytes / windows_logical_disk_size_bytes) * 100 < 10
        for: 2m
        labels:
          severity: critical
        annotations:
          summary: "Low disk space on {{ $labels.instance }} drive {{ $labels.volume }}"

Best Practices

Restrict access to port 9182 on the Windows Server firewall to the Prometheus server IP only—never expose metrics endpoints to the public internet. Configure Prometheus retention to balance storage consumption and historical visibility. Use Grafana alerting or Alertmanager for email and Slack notifications. Add windows_exporter collectors incrementally; start with cpu, memory, logical_disk, net, and service, then add application-specific collectors as needed.