Introduction to Prometheus Monitoring solution
Prometheus is an open-source, modern time series database and toolkit for monitoring and alerting systems in the case of an event or metric gone wrong. In the case of example logs which have information on errors and what not to do, Prometheus gathers little bit of data which are known as metrics about many things to help you understand the state of your system.
It focuses more on reliability than accuracy and that makes it the ideal tool in systems like microservices running in cloud. It is thus not good for systems that require high accuracy like billing applications but can be used in monitoring and alerting.
Some of the features of Prometheus include:
- Client Libraries that define a metric and its control
- Fetches data via a pull model over HTTP known as Scrapping
- No distribution, It stores data locally making it easy to run.
- Data from Prometheus can be used to produce graphs.
- Has PromQL, a powerful and efficient query language for aggregating metrics.
- Alert management system that turns alerts to notifications that can be sent over email or chats.
What is Prometheus Windows Exporter?
A windows exporter is a tool used by windows servers to collect metrics like memory, CPU and disk usage and also can be used as a monitoring system for information systems, network interfaces and applications. A good example is the windows_exporter (formerly WMI) and Node-Exporter which can both be used in conjunction with Prometheus.
It helps system administrators manage different windows operation environments including the remote systems by providing users information about the status of the systems.
In this guide, I will show you how to:
- Install Prometheus server on Windows 11 / Windows 10
- Install Prometheus Windows_Exporter on Windows 11 / Windows 10
- Visualization of collected Metrics with Grafana
You should have a working installation of Grafana for data visualization. This is covered at a later step in this guide. Refer to our guide on the installation of Grafana on Windows:
- Installation of Grafana on Windows system
Install Prometheus on Windows 11 / Windows 10
To install Prometheus, Navigate to Prometheus download site and select the zip file for windows.
Find the downloaded zip file and extract it. You can move the files level up and also rename the folder if you desire.
Install NSSM on Windows 11 / Windows 10
NSSM is a Non-Sucking Service manager that assists an application as a service and ensures that it does not fail. It logs its services in the system event log thus you can look back into it just in case.
To install it, navigate to NSSM downloads and select the latest version and click on it to download.
Find the file and extract it. You also do the same by moving them up a level and rename them to lessen the long names.
For easier access of both files, I moved them to a folder on my desktop named monitoring as shown below.
Then open CMD and change the directory to where nssm is located. It will depend with where you have kept your file.
Then next will be to install Prometheus using the nssm utility. Copy the Prometheus location
Then on the cmd type the command
nssm.exe install prometheus C:\Users\Admin\Desktop\Monitoring\prometheus\prometheus
The service is installed successfully. You can check from the services app and you will find it there as shown below.
Install Windows_Exporter on Windows 11 / Windows 10
To install Windows_Exporter navigate to windows_exporter on GitHub and select one that fits your machine. I chose the 64 bit installer file.
The download starts immediately. Navigate to your downloads and click on the file to install it.
To confirm a successful installation, check on the services app and it will show up there.
You can also check by navigating to localhost:9182 which is the default TCP port for windows_exporter. It opens on a browser and when you click on Metrics it shows the metrics as follows.
Configure Prometheus on Windows 11 / Windows 10
prometheus/yml file by adding another job name at the last section. Open with any editor you have, I chose notepad++ and copied the last section with the job name and targets. I then edited the pasted section to fit windows_exporter as Job name and targets as localhost:9182. Save your work then close the file.
Next is to start the Prometheus service from the services app. Find the prometheus service and click on start.
To see if the connection works, Navigate to localhost:9090 from the browser. It open Prometheus homepage as follows.
To confirm your other job was saved and connected successfully, Navigate to Status>Targets and you will find the two jobs up and running as shown below.
Configure Grafana on on Windows 11 / Windows 10
With Grafana already installed, Navigate to the config file
defaults then enable smtp to ‘true’ as shown below. Its path is
C:\Program Files\GrafanaLabs\grafana\conf. Save the edit. If you encounter an issue trying to save the file, Save it in a different directory like the desktop then copy it back to the folder.
Navigate to localhost:3000 which is the Grafana Homepage. Go to Settings>Data sources>Add Data Source. Select Prometheus DB.
Enter the default port URL for Prometheus which is
http://localhost:9090/. You can name the Data source however you desire.
Scroll down to the Save and Test button and click on it. If you put the correct URL then it will give a prompt of Data Source Working as follows.
Then on the dashboard part. Hover on the plus sign then select Import.
Enter the ID of the dashboard you would like to export. For the default windows URL ID is 2129. I will however use the ID for Windows_Exporter Dashboard which is 14694
Then select the Prometheus database to store the dashboard. I would pick MyPC that I recently created. Click on Import
A dashboard with different panels of different metrics is shown as below.
We have learned about Prometheus and how to install it as a service using NSSM. We have also learned how to configure Grafana to use Prometheus as a data source and import dashboards by use of ID.
Prometheus is powerful and has changed the way systems are being monitored. It has multiple modes for graphing and dashboarding support. It is high-level and that is why it is a top level project by Cloud Native Computing Foundation (CNCF).