Prometheus 監控Windows機器


【1】windows采集器:wmi-exporter

在192.168.191.81 上安裝,采集器默認端口為 9182

【1.1】下載安裝 wmi-exporter

https://github.com/martinlindhe/wmi_exporter/releases

我們在下圖中選擇這個:windows_exporter-0.13.0-amd64.msi

 

  

 下載好后,傳輸到被監控的 windows 機器上去運行

  

 運行了之后,我們發現好像什么都沒有發生,但實際上可能已經安裝好了,我們查看服務

  

 我們來看看它到底是不是,右擊查看它的屬性,看這描述,就是它了。

  

--  這里推薦把啟動類型,修改成自動(延遲啟動)

--  或者可以  cmd命令執行  sc config windows_exporter start= delayed-auto

 我們還可以看看它的執行文件路徑,里面就是它的啟動命令了,原來默認端口是9182啊

"C:\Program Files\windows_exporter\windows_exporter.exe" --log.format logger:eventlog?name=windows_exporter  --telemetry.addr :9182   

從這里可以看出,wim_exporter的日志信息  --log.format logger:eventlog  放入了windows自帶的 eventlog中去了;

【1.2】核驗 wmi_exporter 是否運行

我們在上一個步驟發現它運行了,那么我們如何確定采集器真的再運行呢?

  根據采集器特性,我們用http(192.168.191.81:9182/metrics)訪問它的 metrics 即可。

  這里如果是在客戶端機器上,直接輸入127.0.0.1:9182/metrics 也可以

    

 

【windows_exporter】高級應用(非必須)

官網:https://github.com/prometheus-community/windows_exporter

【1.1】默認配置:默認采集哪些指標呢?

看官網:https://github.com/prometheus-community/windows_exporter

通過官網我們可以看到,它有非常多的采集器,然后默認只采集了幾個分類而已,想知道每個分類指標里面大概采集的那些具體指標,可以點進去看;

  

 

【1.2】額外參數配置

  

 

其實大多都用不到,我們一般只要管

--telemetry.addr :配置自定義端口(當然一般也不用額外配置,默認9182 就不錯)

--collectors.enabled :指定額外的采集指標分類,就是我們該分類1.1中的那些了

案例:

僅啟用服務收集器並指定自定義查詢

.\windows_exporter.exe --collectors.enabled "service" --collector.service.services-where "Name='windows_exporter'"

僅啟用流程收集器並指定自定義查詢

.\windows_exporter.exe --collectors.enabled "process" --collector.process.whitelist="firefox.+"

當有多個同名進程時,WMI將第一個實例之后的進程表示為process-name#index因此,要獲取所有內容,而不僅僅是第一個,則正則表達式必須使用.+有關更多信息,請參見過程

【1.3】最佳實踐

  

 

 config.yml

collectors:
  enabled: cpu,cs,logical_disk,net,os,service,system,textfile,mssql
collector:
  service:
    services-where: "Name='windows_exporter'"
log:
  level: warn

start.bat

windows_exporter --config.file=config.yml

 

如果只是簡單用一下:推薦

.\windows_exporter.exe --collectors.enabled "cpu,cs,logical_disk,net,os,service,system,textfile,mssql" --collector.service.services-where "Name='windows_exporter'"

 

 

【2】prometheus 配置

這里我們的 prometheus 服務器是 192.168.175.131,端口:9090

PS:安裝方面的就不講了(有興趣的可以看我這個文章分類下的其他文章),這里預設是已經安裝好正在運行的 prometheus 服務器

【2.1】修改Prometheus.yml 添加 windows 機器

我在配置文件中添加了下列紅框中的代碼;

  

【2.2】在線重載 Prometheus 配置文件

在prometheus 服務器端運行,或者直接在外部網頁上運行也可以,不過localhost 要改成服務器端的 IP地址

curl -X POST http://localhost:9090/-/reload

【2.3】核驗節點與prometheus服務器是否聯通

  

【3】Grafana 配置與顯示

【3.1】windows 儀表盤模板

官網:https://grafana.com/grafana/dashboards?dataSource=prometheus

  

 

 我的prometheus 服務器端 可以聯網,我就直接用這個儀表盤ID了。如下圖,ID是 10467

  

 

【3.2】導入windows儀表盤模板

  

 

輸入儀表盤ID,然后點擊 Load

   

 

 選擇好數據源然后導入

  

 

【3.3】查看新導入的windows儀表盤

   

到這里,就完成成功了!

 

【參數解析】

參數解析轉自:https://blog.csdn.net/qq_38311845/article/details/105279963

GO參數

參數名 參數解釋
go_gc_duration_seconds GC調用持續時間的摘要
go_goroutines 當前存在的goroutine數量
go_info 有關Go環境的信息
go_memstats_alloc_bytes 已分配且仍在使用的字節數
go_memstats_alloc_bytes_total 已分配的總字節數,即使已釋放也是如此
go_memstats_buck_hash_sys_bytes 分析存儲桶哈希表使用的字節數(標尺)
go_memstats_frees_total 空閑總數(計數器)
go_memstats_gc_cpu_fraction 自程序啟動以來,GC使用該程序的可用CPU時間的分數
go_memstats_gc_sys_bytes 用於垃圾回收系統元數據的字節數
go_memstats_heap_alloc_bytes 已分配且仍在使用的堆字節數
go_memstats_heap_idle_bytes 等待使用的堆字節數
go_memstats_heap_inuse_bytes 正在使用的堆字節數
go_memstats_heap_objects 分配的對象數
go_memstats_heap_released_bytes 已釋放到OS的堆字節數
go_memstats_heap_sys_bytes 從系統獲取的堆字節數
go_memstats_last_gc_time_seconds 自1970年以來的最后一次垃圾回收的秒數
go_memstats_lookups_total 指針查找總數
go_memstats_mallocs_total malloc總數
go_memstats_mcache_inuse_bytes mcache結構正在使用的字節數
go_memstats_mcache_sys_bytes 用於從系統獲取的mcache結構的字節數
go_memstats_mspan_inuse_bytes mspan結構使用的字節數
go_memstats_mspan_sys_bytes 用於從系統獲取的mspan結構的字節數
go_memstats_next_gc_bytes 下一次垃圾回收發生時的堆字節數
go_memstats_other_sys_bytes 用於其他系統分配的字節數
go_memstats_stack_inuse_bytes 堆棧分配器正在使用的字節數
go_memstats_stack_sys_bytes 從系統獲取的用於堆棧分配器的字節數
go_memstats_sys_bytes 從系統獲取的字節數
go_threads 創建的OS線程數
   

 

process參數

參數名 參數解釋
process_start_time_seconds 自unix紀元以來的進程開始時間(以秒為單位)

 

cpu參數

參數名 參數解釋
wmi_cpu_clock_interrupts_total 接收和服務的時鍾滴答中斷總數
wmi_cpu_core_frequency_mhz 核心頻率(兆赫)
wmi_cpu_cstate_seconds_total 在低功耗空閑狀態下花費的時間
wmi_cpu_dpcs_total 接收和服務的延遲過程調用(DPC)總數
wmi_cpu_idle_break_events_total 處理器從空閑狀態喚醒的總時間
wmi_cpu_interrupts_total 接收和服務的硬件中斷總數
wmi_cpu_parking_status 停車狀態表示處理器是否已停車
wmi_cpu_processor_performance 處理器性能是處理器執行指令時的平均性能,占處理器標稱性能的百分比
wmi_cpu_time_total 處理器在不同模式(空閑,用戶,系統等)上花費的時間
   

 

ComputerSystem參數

參數名 參數解釋
wmi_cs_hostname 由ComputerSystem.DNSHostName和ComputerSystem.Domain提供的帶標簽的系統主機名信息
wmi_cs_logical_processors ComputerSystem.NumberOfLogicalProcessors
wmi_cs_physical_memory_bytes ComputerSystem.TotalPhysicalMemory
   

 

wmi_exporter參數

參數名 參數解釋
wmi_exporter_build_info 帶有常量'1'值的度量標准,用於構建wmi_exporter
wmi_exporter_collector_duration_seconds wmi_exporter:收集的持續時間
wmi_exporter_collector_success wmi_exporter:收集器是否成功
wmi_exporter_collector_timeout wmi_exporter:收集器是否超時
wmi_exporter_perflib_snapshot_duration_seconds perflib快照捕獲的持續時間
   

 

logical(磁盤)參數

參數名 參數解釋
wmi_logical_disk_free_bytes 以字節為單位的可用空間
wmi_logical_disk_idle_seconds_total 磁盤空閑的秒數(可以用irate表示磁盤空閑率)
wmi_logical_disk_read_bytes_total 讀取操作期間從磁盤傳輸的字節數
wmi_logical_disk_read_latency_seconds_total 顯示從磁盤進行讀取操作的平均時間(以秒為單位)
wmi_logical_disk_read_seconds_total 磁盤正在忙於處理讀取請求的秒數
wmi_logical_disk_read_write_latency_seconds_total 顯示以秒為單位的平均磁盤傳輸時間
wmi_logical_disk_reads_total 磁盤上的讀取操作數
wmi_logical_disk_requests_queued 排隊到磁盤的請求數
wmi_logical_disk_size_bytes 總空間(以字節為單位)
wmi_logical_disk_split_ios_total 磁盤的I / O數量分為多個I / O
wmi_logical_disk_write_bytes_total 寫入操作期間傳輸到磁盤的字節數
wmi_logical_disk_write_latency_seconds_total 顯示對磁盤執行寫入操作的平均時間(以秒為單位)
wmi_logical_disk_write_seconds_total 磁盤忙於處理寫請求的秒數
wmi_logical_disk_writes_total 磁盤上的寫操作數
   

 

net 參數

參數名 參數解釋
wmi_net_bytes_received_total 接收的網絡字節數
wmi_net_bytes_sent_total 發送的網絡字節數
wmi_net_bytes_total 網絡字節總數
wmi_net_current_bandwidth 網絡當前帶寬
wmi_net_packets_outbound_discarded 網絡丟棄出站的數據包
wmi_net_packets_outbound_errors 網絡數據包出站錯誤
wmi_net_packets_received_discarded 網絡丟棄接收的數據包
wmi_net_packets_received_errors 網絡數據包接收錯誤
wmi_net_packets_received_total 接收到的包
wmi_net_packets_received_unknown 網絡收到未知的數據包
wmi_net_packets_sent_total 網絡發送的數據包
wmi_net_packets_total 網絡包總數
   

 

OS 系統參數

參數名 參數解釋
wmi_os_info 操作系統-標題 操作系統-版本
wmi_os_paging_free_bytes 分頁文件中的空閑空間
wmi_os_paging_limit_bytes 存儲在分頁文件中的大小
wmi_os_physical_memory_free_bytes 釋放物理內存
wmi_os_process_memory_limix_bytes 最大進程內存大小
wmi_os_processes 進程數
wmi_os_processes_limit 最大進程數
wmi_os_time 本地日期時間
wmi_os_users 用戶數
wmi_os_virtual_memory_bytes 總虛擬內存大小
wmi_os_virtual_memory_free_bytes 空閑虛擬內存
wmi_os_visible_memory_bytes 總可見內存大小
   

 

service 系統服務參數

參數名 參數解釋
wmi_service_start_mode 服務的啟動模式(StartMode)
wmi_service_state 服務狀態(狀態)
wmi_service_status wmi_服務狀態
   

 

service 參數

參數名 參數解釋
wmi_system_context_switches_total 上下文開關總數(WMI源:PerfOS_System.contextswitchessepersec)
wmi_system_exception_dispatches_total 調度的異常總數(WMI源:PerfOS_System.ExceptionDispatchesPersec)
wmi_system_processor_queue_length 處理器隊列的長度(WMI源:PerfOS_System.processor queue Length)
wmi_system_system_calls_total 系統調用總數(WMI源:PerfOS_system.SystemCallsPersec)
wmi_system_system_up_time 系統啟動時間(WMI源:PerfOS_System.SystemUpTime)
wmi_system_threads wmi_system_線程
wmi_textfile_scrape_error 如果打開或讀取文件時出錯,則為1;否則為0


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM