Configuring Windows Server Monitoring with Prometheus: A Comprehensive Guide with 3 Steps

Step 1: Installing WMI Exporter on the Windows Server

To monitor your Windows server with Prometheus, you’ll need to install the WMI exporter on the server you want to monitor. You can download the latest version of the exporter from here, and then install it using the standard Windows installer.

Once the exporter is installed, you can check that the “windows_exporter” service is running in the Services panel. This service is responsible for exporting the metrics from the Windows server to the Prometheus server, allowing you to monitor key system metrics such as CPU usage, memory usage, and disk I/O.

By combining the WMI exporter with Prometheus and Grafana, you can gain deep insights into your Windows server’s performance and quickly identify any issues that may be impacting your system’s stability or reliability.

Step 2: Deploy a server and install Prometheus

To begin monitoring your Windows server with Prometheus and Grafana, you’ll need to create a dedicated server instance. Don’t worry if you don’t have one already – you can easily spin up a new server of your choice. For the purposes of this guide, I’ll be using Ubuntu 20.04, but feel free to use any other distribution that you prefer. Once you’ve logged in as root user, you can proceed with installing the Prometheus and Grafana services to start monitoring your server’s performance.

To download Prometheus on your Linux server, you can use the “wget” command and specify the download link for the latest version. For instance, you can run the following command to download version 2.43.0:

wget https://github.com/prometheus/prometheus/releases/download/v2.43.0/prometheus-2.43.0.linux-amd64.tar.gz

Keep in mind that the download link may change over time, so it’s always recommended to get the latest version.

After downloading the Prometheus archive file, you’ll need to extract its contents. To do this, you can use the “tar” command with the “xzf” option to extract the file:

tar xzf prometheus-2.43.0.linux-amd64.tar.gz

This command will extract the contents of the “prometheus-2.43.0.linux-amd64.tar.gz” file to a new directory called “prometheus-2.43.0.linux-amd64” in the current working directory.

Once you’ve extracted the Prometheus archive file, you can navigate to the extracted directory using the “cd” command. For example, you can run:

cd prometheus-2.43.0.linux-amd64

From there, you can copy all the contents of the directory to “/usr/local/bin/prometheus”. To do this, you can use the “cp” command with the “-r” option to copy the directory recursively:

cp -r . /usr/local/bin/prometheus

This command will copy all the files and subdirectories within the “prometheus-2.43.0.linux-amd64” directory to the “/usr/local/bin/prometheus” directory on your server

After installing Prometheus on your server, you’ll need to configure for Windows server monitoring. To do this, you can edit the “prometheus.yml” configuration file using a text editor like Vim. For instance, you can run:

sudo vim /usr/local/bin/prometheus/prometheus.yml

This will open the file in Vim. Next, you can add the following code block to the file:

global:
     scrape_interval: 10s

scrape_configs:
     – job_name: ‘windows-server’
        scrape_interval: 5s
        static_configs:
           – targets: [‘<windows-server-ip>:9182’]

Be sure to replace “<windows-server-ip>” with the private IP address of your target Windows server. You can also modify the port number “9182” to match the port number of the Prometheus exporter service that you will install on the Windows server in a later step. If you need to monitor multiple Windows servers, you can add them to the “targets” array separated by commas.

To save and exit the file in Vim, you can type “:wq” (without quotes) and press Enter. This will write the changes to the file and quit Vim.

After configuring Prometheus to monitor your Windows server, you’ll need to set up the Prometheus service so that it starts automatically when your server boots up. To do this, you can create a new systemd service file for Prometheus by running:

sudo vim /etc/systemd/system/prometheus.service

Then, you can copy and paste the following code into the file:

[Unit]
Description=Prometheus Service
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/prometheus/prometheus –config.file=/usr/local/bin/prometheus/prometheus.yml

[Install]
WantedBy=multi-user.target

This configuration specifies that the Prometheus service should start after the network is up, and it sets the “ExecStart” parameter to point to the location of the Prometheus binary and configuration file. Once you’ve added this code to the file, you can save and close it by typing “:wq” (without quotes) and pressing Enter.

To start the Prometheus service and check its status, you can use the following commands:

sudo systemctl start prometheus

sudo systemctl status prometheus

The first command will start the service, while the second command will show you whether the service is running and any relevant logs or errors. With Prometheus up and running, you can move on to installing Grafana and visualizing your server metrics in real time!

Step 3: Check if Prometheus is running and successfully collecting metrics from your server

To access Prometheus, log in with your prometheus server’s IP address and port 9090 (<prometheus_server_ip>:9090). Then, navigate to the “Status” tab and select “Targets” to view the server’s status and ensure that it’s operational with an “up” state.

In my next blog post, I’ll guide you through the steps of installing Grafana and integrating it with Prometheus for improved visualization of your server metrics. Stay tuned for more!

Add a Comment

Your email address will not be published. Required fields are marked *