In this article we are going to cover How Install Install Prometheus and Grafana on Windows with WMI Exporter, Configure Prometheus as Grafana DataSource.
Table of Contents
What is prometheus?
- Prometheus is a open source Linux Server Monitoring tool mainly used for metrics monitoring, event monitoring, alert management, etc.
- Prometheus has changed the way of monitoring systems and that is why it has become the Top-Level project of Cloud Native Computing Foundation (CNCF).
- Prometheus uses a powerful query language i.e. “PromQL”.
- In Prometheus tabs are on and handles hundreds of services and microservices.
- Prometheus use multiple modes used for graphing and dashboarding support.
Why we used prometheus?
- A multi-dimensional data model with time series data identified by metric name and key/value pairs
- PromQL, a flexible query language to leverage this dimensionality
- Pushing time series is supported via an intermediary gateway
- Multiple modes of graphing and dashboarding support
Prometheus Architecture
- As above we can see an architecture of Prometheus monitoring tool.
- We made a basic design to understand it easily for you people.
Now lets understand the Prometheus components one-by-one
Prometheus Components
1. Prometheus Server
- Prometheus server is a first component of Prometheus architecture.
- Prometheus server is a core of Prometheus architecture which is divided into several parts like Storage, PromQL, HTTP server, etc.
- In Prometheus server data is scraped from the target nodes and then stored in the database.
1.a. Storage
- Storage in Prometheus server has a local on disk storage.
- Prometheus has many interfaces that allow integrating with remote storage systems.
1.b. PromQL
- Prometheus uses its own query language i.e. PromQL which is a very powerful querying language.
- PromQL allows the user to select and aggregate the data.
2. Service Discovery
- Next and very important component of Prometheus Server is the Service Discovery.
- With the help of Service discovery the services are identified which need to be scraped.
- To Pull metrics, identification of services and finding the targets are compulsory needed.
- Through Service discovery we monitor the entities and can also locate its targets.
3. Scrape Target
- Once the services are identified and the targets are ready then we can pull metrics from it and can scrape the target.
- We can export the data of the end point using node exporters.
- Once the metrics or other data is pulled, Prometheus stores it in a local storage.
4. Alert Manager
- Alert Manager handles the alerts which may occurs during the session.
- Alert manager handles all the alerts which are sent by the Prometheus server.
- Alert manager is one of the very useful components of the Prometheus tool.
- If in case any big error or any issue occurs, alert manager manage those alerts and contact with human via E-mail, Text Messages, On-call, or any other chat application service.
5. User Interface
- User interface is also an important component as it builds a bridge between the user and the system.
- In Prometheus, user interfaces are note that much user friendly and can be used till graph queries.
- For good exclusive dashboards Prometheus works together with Grafana (visualization tool).
- Using Grafana over Prometheus to visualize properly we can use custom dashboards.
- Grafana dashboards display via pie charts, line charts, tables, good data graphs of CPU usage, RAM utilization, network load, etc with indicators.
- Grafana supports and run with Prometheus by querying language i.e. PromQL.
- To fetch data from Prometheus and to display the results on Grafana dashboards PromQL is used.
What is Grafana ?
- Grafana is a free and open source visualization tool mostly used with Prometheus to which monitor metrics.
- Grafana provides various dashboards, charts, graphs, alerts for the particular data source.
- Grafana allows us to query, visualize, explore metrics and set alerts for the data source which can be a system, server, nodes, cluster, etc.
- We can also create our own dynamic dashboard for visualization and monitoring.
- We can save the dashboard and can even share with our team members which is one of the main advantage of Grafana.
What is WMI Exporter?
- It is same like Node Exporter but Node Exporter for Linux and WMI Exporter for Windows
- WMI Exporter is an exporter utilized for windows servers to collects metrics like CPU usage, memory, and Disk usage.
- It is open-source which can be installed on Windows servers using the .msi installer
Prerequisite:
- Good internet connectivity
- Security Groups Configured properly
- Any web Browser
Security Groups Configured on EC2 Instances
- Port 9090 — Prometheus Server
- Port 9182—-WMI Exporter
- Port 3000 — Grafana
How to Install Prometheus and Grafana on Windows
#1. Download Prometheus for windows
Now we will download the latest version of Prometheus. We can copy the download link as per our Operating System from Prometheus download page
Using the below command we can download Prometheus, here we are downloading Prometheus 2.32.1 version, you use the above link to download specific version.
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 2](https://www.fosstechnix.com/wp-content/uploads/2021/12/download-prometheus.png)
We have to install prometheus service but in windows we can not installl prometheus as a service for that here im using NSSM package to install Prometheus service
Open your command prompt run as administrator
Paste the directory path like below command:
cd c:\users\Administrator\Downloads\nssm-2.24\nssm-2.24\win64
dir
nssm.exe install prometheus<<and your prometheus application directory path>> \prometheus
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 3](https://www.fosstechnix.com/wp-content/uploads/2021/12/install-prometheus-on-window.png)
Now Prometheus is successfully installed in your machine
So let’s check the status in prometheus service on windows.
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 4](https://www.fosstechnix.com/wp-content/uploads/2021/12/start-prometheus.png)
For now Prometheus is stop after changing in configuration file we will start prometheus
After installation now we are going to install Grafana on Window
#2. Install Grafana on Windows
Now we will download the latest version of Grafana.from official page of Grafana select window operating system and download .msi installer
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 5](https://www.fosstechnix.com/wp-content/uploads/2021/12/download-grafana.png)
After download of grafana we will install grafana on window
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 6](https://www.fosstechnix.com/wp-content/uploads/2021/12/install-grafana.png)
After installation of Grafana go to C:<<Program Files<<GrafanaLabs<<Grafana<< conf<<defaults
In default change the smtp enabled false replace with true you can check the below image
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 7](https://www.fosstechnix.com/wp-content/uploads/2021/12/smtp.png)
To access Grafana Dashboard open your favorite browser, type server IP or Name followed by grafana default port 3000.
http://localhost:3000
Here you can see Login page of Grafana now you will have to login with below Grafana default UserName and Password.
Username – admin
Password – admin
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 8](https://www.fosstechnix.com/wp-content/uploads/2021/12/login-to-grafana-2.png)
It is always a good practice to change your login credentials.
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 9](https://www.fosstechnix.com/wp-content/uploads/2021/12/enter-new-pass-to-grafana-2.png)
Provide your New Password and click on Change Password
Now here you can see Home Dashboard page of Grafana
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 10](https://www.fosstechnix.com/wp-content/uploads/2021/12/welcome-grafana-1024x411.png)
#3. Install WMI Exporter on Windows
For Windows hosts, you are going to use the Windows exporter.
You can download the latest version of windows installer from here
When the download is done, simply click on the MSI file and start running the installer.
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 12](https://www.fosstechnix.com/wp-content/uploads/2021/12/install-wmi-exporter-3.png)
After Installation of WMI Exporter lets check its successfully installed or not
So go to services and search windows exporter.
Make sure windows exporter service is running.
Now that your exporter is running, it should start exposing metrics on
http://localhost:9182/metrics
So let’s check
#4. Update Prometheus Configuration file
Go to the Prometheus file and open Prometheus.yml file and
Update config file with below code:
- job_name: "WMI Exporter"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["Host_ip:9182"]
Now save the file and exit
After changing in config file you need to start prometheus server
So go the services and start the Prometheus Server
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 15](https://www.fosstechnix.com/wp-content/uploads/2021/12/prometheus-start-1.png)
Hit the URL in your web browser to check weather our target is successfully scraped by Prometheus or not
https://localhost:9090/targets
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 16](https://www.fosstechnix.com/wp-content/uploads/2021/12/prometheus-target-1024x378.png)
#4. Configure Prometheus as Grafana DataSource
Once you logged into Grafana Now first Navigate to Settings Icon ->> Configuration ->> data sources
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 17](https://www.fosstechnix.com/wp-content/uploads/2021/12/configuration-on-grafana-2-1024x415.png)
Now lets click on Add Data sources and select Prometheus
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 18](https://www.fosstechnix.com/wp-content/uploads/2021/12/add-data-source-4-1024x576.png)
Now configure Prometheus data source by providing Prometheus URL
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 19](https://www.fosstechnix.com/wp-content/uploads/2021/12/config-grafana.png)
As per your requirement you can do other changes or you can also keep remaining configuration as default.
Now click on Save & test so it will prompt a message Data Source is working.
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 20](https://www.fosstechnix.com/wp-content/uploads/2021/12/data-source-is-working-2-1024x369.png)
#5.Creating Grafana Dashboard to monitor Windows server
Now lets build a dashboard in Grafana so then it will able to reflect the metrics of the Windows system.
So we will use 14510 to import Grafana.com, Lets come to Grafana Home page and you can see a “+” icon. Click on that and select “Import”
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 21](https://www.fosstechnix.com/wp-content/uploads/2021/12/import-grafana-to-linux-server-5-1024x399.png)
On the next window, simply enter the dashboard ID in the corresponding field
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 22](https://www.fosstechnix.com/wp-content/uploads/2021/12/import-14510-for-windows-2.png)
Now provide the name and select the Prometheus Datasource and click on Import.
![Install Prometheus and Grafana on Windows with WMI Exporter [4 Steps] 23](https://www.fosstechnix.com/wp-content/uploads/2021/12/importing-dashboard-for-windows-2.png)
There you are done with the setup. Now your Dashboard is running up!.
Conclusion:
In this article we have covered How Install Install Prometheus and Grafana on Windows with WMI Exporter, Configure Prometheus as Grafana DataSource.
Related Articles:
Good article.
For me Prometheus got connected over http instead of https i.e. “http://localhost:9090/targets”
Thanks for the article! it really helped me!
when i try to start the prometheus services its causes below issue:
Windows could not start prometheus service in local computer.The service did not run an error. This could be an internal windows error or an internal service error. If the problem persists, contact your system administrator.
You need to move the Prometheus folder from downloads to another folder like C:/. Also, turn Windows SmartScreen Off. Also, if those 2 don’t work, check your YAML spacing, its tricky.
I am unable to capture 90 percentile value from Jmeter when running Prometheus on windows, I was able to capture 95 and 99 percentile value. Which value should I pass in Jmeter to capture in prometheus listener
Hello Raj,
You can use like this promql query –
histogram_quantile(0.9, rate(http_request_duration_seconds_bucket[10m]))
Hello!
On a windows 2008r2 server, the prometheus service does not start with an error:
“Service prometheus ran for less than 1500 milliseconds. Restart will be delayed by 2000 milliseconds.”