How to Monitor Linux and Windows with Prometheus and Grafana
April 15, 2025
Monitoring Windows and Linux with Prometheus and Grafana
One of the most useful things about using Prometheus to collect metrics is how versatile it is as a solution. There are metric exporters available for a variety of services, hypervisors and operating systems - including Windows.
“Why post about Windows?” you may ask. Well, the reality of many IT systems and environments is that they are not “greenfield” sites, but are rather “brownfield” - places that have been built on before, meaning that you may not have the luxury of starting from scratch - and very often a combination of different operating systems running different workloads.
Just as the many modern cities are built on - or even around - their ancient predecessors and landscape features, you may have a need to fit existing systems into whatever environment you encounter.
Monitoring of Windows and Linux together should be thought of in such a context - being able to pull metrics from both operating systems and present them on the same dashboards is a huge advantage over running separate systems which would need separate logins to access and administer.
This post covers the setup for both Windows and Linux, and it goes without saying that you can do one, the other or both and add them to the same Prometheus configuration.
Environment Setup
The easiest way to configure Grafana, Prometheus and the relevant exporters is to use Docker containers. The instructions for the initial part of the setup can be found here, and you will need to have this (or and existing Prometheus and Grafana environment) configured before setting up the Linux and Windows node exporters.
Windows Exporter
Setting up a Windows Exporter requires you to install the exporter software on each Windows Server you want to monitor. The exporter software can be downloaded from the Prometheus community github here.
If you are happy to use the default metrics, you can simply run the MSI installer on the server. The default collectors are listed here on the Github documentation pages.
For more advanced installations, you may wish to specify a config file defining options, including collectors to use.
msiexec /i <path-to-msi-file> --% CONFIG_FILE="D:\config.yaml"
The Windows Exporter will be installed as a service called “windows_exporter” which can be started as a normal service.
Metrics are available by default on port 9182 - you should be able to access these using http://hostname:9182 in a web browser.
Note: If you have a need to install the Windows Exporter to many servers, you may wish to use Active Directory to deploy the exporter to them - see the following post.
When you have installed your Windows Exporter(s) on your servers, you should now configure Prometheus to connect to these.
In your prometheus config file, add the following:
scrape_configs: # add this line if scrape_configs does not exist - otherwise add jobs.
- job_name: 'WindowsServers'
static_configs:
- targets: ['192.168.2.20:9182','192.168.2.21:9182'] # 'hostname:port' array, comma separated.
metrics_path: /metrics
You now need to restart the prometheus container to refresh the configuration - if you have followed the example setup, this can be done by running the following:
sudo docker restart prometheus
If not, you will have to identify the prometheus container using the following to find all running containers:
sudo docker ps
Metrics should be shown in a minute or two - you can also check these by accessing http://prometheushost:port/targets, eg http://192.168.2.10:9090/targets
Linux Exporter
The Linux node exporter requires more manual installation than Windows, and for the application to be configured as a service manually.
For ubuntu, the process is as follows. Get the latest installer from the prometheus github, extract it and copy the binary to /usr/local/bin:
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz
tar xvfz node_exporter-*.*-amd64.tar.gz
cp node_exporter-*.*-amd64/node_exporter /usr/local/bin
You now need to create the systemd unit file to be able to run as a service.
Create the file using:
sudo nano /etc/systemd/system/node_exporter.service
Enter the following details:
[Unit]
Description=Prometheus Node Exporter
After=network.target
[Service]
User=node_exporter
Group=node_exporter
ExecStart=/usr/local/bin/node_exporter
Restart=always
[Install]
WantedBy=multi-user.target
Save the file and then run:
useradd -r node_exporter
sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
The first command adds a node_exporter user to the machine, whilst the others force the systemctl daemon to detect the configuration, start the exporter as a service and enable it to run as a service in the event of a reboot.
You should now be able to access the metrics on the server hostname / IP on port 9100, eg http://linuxexporteraddress:9100
As with the Windows setup, when the Linux servers are configured the prometheus configuration needs to be updated with the hostname/IP and port addresses of each node, eg:
scrape_configs: # add this line if scrape_configs does not exist - otherwise add jobs.
- job_name: 'LinuxServers'
static_configs:
- targets: ['linuxexporteraddress:9100'] # 'hostname:port' array, comma separated.
With this configured, you should restart the prometheus service and check the targets as described in the Windows section above.
Demonstration Videos
Windows Exporter setup:
Linux node exporter setup: