一、安裝wmi-exporter 首先在需要監控的Windows機器上安裝wmi_exporter。wmi_exporter下載地址:https://github.com/martinlindhe/wmi_exporter/releases 下載後,雙擊即可完成安裝。 完成安裝後,會自動創建一個開機 ...
一、安裝wmi-exporter
首先在需要監控的Windows機器上安裝wmi_exporter。wmi_exporter下載地址:https://github.com/martinlindhe/wmi_exporter/releases
下載後,雙擊即可完成安裝。
完成安裝後,會自動創建一個開機自啟的服務
驗證服務是否啟動,預設wmi-exporter埠為9182
瀏覽器訪問 http://192.168.56.1:9182/metrics (Windows系統IP地址:9182埠),顯示數據,則服務開啟成功。
二、修改Prometheus配置
進入Prometheus的安裝文件夾,打開Prometheus配置文件
# cd /usr/local/prometheus
# vim prometheus.yml
在scrape_configs標簽下,添加以下內容,配置監控
- job_name: 'Windows'
static_configs:
- targets: ['192.168.56.1:9182']
labels:
instance: Windows
以下是Prometheus.yml 文件全部內容
# 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
保存退出,重啟Prometheus服務
# systemctl restart prometheus
瀏覽器訪問 http://192.168.56.200:9090/targets 查看監控信息
可以看到,Windows機器已經加入進來。
三、配置Grafana
添加dashboard
Grafana官方為我們提供了很多dashboard頁面,可直接下載使用。瀏覽器訪問 https://grafana.com/grafana/dashboards 下載所需要的dashboard頁面
此處我們使用Windows 監控的dashboard,dashboard Id為:10467
然後打開我們的Grafana監控頁面,打開dashboard的管理頁面
點擊【import】按鈕
然後將我們剛纔的dashboard Id (10467) 複製進去
Grafana會自動識別dashboard Id 。
然後點擊【change】按鈕,生成一個隨機的UID,然後點擊下方輸入框,選擇我們之前創建的數據源Prometheus,最後點擊【Import】按鈕,即可完成導入。
導入成功後,會自動打開該Dashboard,即可看到我們剛纔設置好的Windows監控
至此Prometheus監控Windows機器,配置完成。