I. install WMI exporter
First install the WMI? Exporter on the Windows machine you want to monitor. Download address of WMI exporter: https://github.com/martinlindhe/wmi_exporter/releases
After downloading, double-click to complete the installation.
After the installation is completed, a self starting service will be created automatically
Verify whether the service is started. The default WMI exporter port is 9182
Browser access http://192.168.56.1:9182/metrics (IP address of Windows system: port 9182). If data is displayed, the service is started successfully.
II. Modify Prometheus configuration
Enter the installation folder of Prometheus and open the Prometheus configuration file
# cd /usr/local/prometheus # vim prometheus.yml
Add the following under the "graph" config tab to configure monitoring
- job_name: 'Windows' static_configs: - targets: ['192.168.56.1:9182'] labels: instance: Windows
Here is the full contents of Prometheus.yml file
# my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9090'] - job_name: 'Linux' static_configs: - targets: ['192.168.56.201:9100'] labels: instance: Linux - job_name: 'Windows' static_configs: - targets: ['192.168.56.1:9182'] labels: instance: Windows
Save exit, restart Prometheus service
# systemctl restart prometheus
Browser access http://192.168.56.200:9090/targets View monitoring information
You can see that the Windows machine has joined in.
III. configure Grafana
Grafana officially provides us with many dashboard pages, which can be downloaded and used directly. Browser access https://grafana.com/grafana/dashboards Download the required dashboard page
Here we use the dashboard monitored by Windows with the ID of 10467
Then open our Grafana monitoring page, open the dashboard management page
Click the [import] button
Then copy in our dashboard Id (10467)
Grafana will automatically recognize the dashboard Id.
Then click the [change] button to generate a random UID, click the input box below, select the data source Prometheus we created earlier, and finally click the [Import] button to complete the Import.
After importing successfully, the Dashboard will be opened automatically, and you can see the Windows monitoring we just set up
Now Prometheus monitors the Windows machine and completes the configuration.