Prometheus (metrics database and alerting) and Grafana (dashboards) are the most popular open-source monitoring stack. Even if your company uses a commercial tool, building this in a lab teaches you how metrics monitoring really works – and the PromQL skills are in high demand.
Lab: one Ubuntu VM (Docker installed) for Prometheus and Grafana, and one or more Windows Server VMs to monitor.
How it fits together
Windows server Ubuntu monitoring VM
windows_exporter :9182 ◄─scrape── Prometheus :9090 ──► Grafana :3000
│
alert rules → Alertmanager → email/chat
Prometheus pulls (“scrapes”) metrics over HTTP every few seconds from exporters running on each target.
1. Install windows_exporter on Windows
Download the latest windows_exporter MSI from the project’s GitHub releases page (prometheus-community/windows_exporter) and install it:
msiexec /i windows_exporter-<version>-amd64.msi ENABLED_COLLECTORS="cpu,memory,logical_disk,net,os,service,system" /qn
It runs as a Windows service and listens on port 9182. Check it:
Invoke-WebRequest http://localhost:9182/metrics -UseBasicParsing | Select-Object -ExpandProperty Content | Select-Object -First 20
Allow port 9182 in the Windows Firewall only from the Prometheus server:
New-NetFirewallRule -DisplayName 'windows_exporter from Prometheus' -Direction Inbound -Protocol TCP -LocalPort 9182 -RemoteAddress 10.0.1.41 -Action Allow
2. Run Prometheus and Grafana
On the Ubuntu VM, prometheus.yml:
global:
scrape_interval: 15s
rule_files:
- alerts.yml
scrape_configs:
- job_name: windows
static_configs:
- targets: ['10.0.1.11:9182', '10.0.1.12:9182']
labels:
env: lab
Start both with Docker:
docker run -d --name prometheus -p 9090:9090 \
-v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml \
-v $PWD/alerts.yml:/etc/prometheus/alerts.yml \
prom/prometheus
docker run -d --name grafana -p 3000:3000 grafana/grafana
Open http://<vm>:9090/targets – both Windows servers should show UP.
3. PromQL you’ll actually use
CPU busy % per server (5-minute average):
100 - (avg by (instance) (rate(windows_cpu_time_total{mode="idle"}[5m])) * 100)
Memory used %:
100 * (1 - windows_memory_available_bytes / windows_cs_physical_memory_bytes)
Free disk % per volume:
100 * windows_logical_disk_free_bytes{volume!~"HarddiskVolume.*"} / windows_logical_disk_size_bytes{volume!~"HarddiskVolume.*"}
Is a service running?
windows_service_state{name="w3svc", state="running"}
rate() turns ever-increasing counters into per-second values – that’s the most important PromQL function to understand. Metric names can change between exporter versions; check your exporter’s /metrics output if a query returns nothing.
4. An alert rule
alerts.yml:
groups:
- name: windows
rules:
- alert: WindowsDiskLow
expr: 100 * windows_logical_disk_free_bytes{volume!~"HarddiskVolume.*"} / windows_logical_disk_size_bytes{volume!~"HarddiskVolume.*"} < 10
for: 15m
labels:
severity: warning
annotations:
summary: "{{ $labels.instance }} volume {{ $labels.volume }} below 10% free"
runbook: "https://wiki.example.local/runbooks/disk-space"
- alert: WindowsExporterDown
expr: up{job="windows"} == 0
for: 5m
labels:
severity: critical
annotations:
summary: "{{ $labels.instance }} is not reporting metrics"
for: 15m means the condition must hold for 15 minutes before firing – no alerts for brief spikes. Route alerts to email or chat with Alertmanager.
5. Grafana dashboard
- Open
http://<vm>:3000(first login admin/admin – change it). - Connections → Data sources → Add → Prometheus, URL
http://<vm-ip>:9090. - Dashboards → New → Import, and import a community Windows dashboard for windows_exporter from grafana.com – or build your own panels with the queries above.
Start your own dashboard with four panels: CPU %, memory %, lowest free disk %, and services not running.
FAQ
Pull vs push – what if Prometheus can’t reach the servers? Run Prometheus (or an agent) inside the same network zone, or use an agent that pushes (e.g. Grafana Alloy) to a central store.
What’s next
Next: Designing alerts and dashboards that people trust.
Practise this topic
Test yourself with free questions on this topic – instant answers and explanations.
Start practice questionsMonitoringPrometheusGrafanaWindows ServerIntermediate