winlogbeat采集windows系統日志


 


官網手冊:https://www.elastic.co/guide/en/beats/winlogbeat/7.5/winlogbeat-installation.html

必看文檔:https://blog.csdn.net/UbuntuTouch/article/details/103170326

【1】下載安裝 winlogbeat

Download Link: https://www.elastic.co/downloads/beats/winlogbeat

我們可以根據自己的版本(和Elasticsearch一樣的版本)來進行下載。(這里我的是7.5.1)

  

 

 如上圖,歷史版本需要點一下,不然下的默認是最新版本,現在已經是 7.15.2 了

下載后,解壓縮內容並將生成的Winlogbeat文件夾放置在系統上您認為合適的任何位置。

比如針對我的設置,我解壓到如下的目錄:

  

 

【2】修改配置文件 winlogbeat.yml

(2.0)總配置查看

復制代碼
#======================= Winlogbeat specific options 
# The supported keys are name (required), tags, fields, fields_under_root,
# forwarded, ignore_older, level, event_id, provider, and include_xml. Please
# visit the documentation for the complete details of each option.
# https://go.es.io/WinlogbeatConfig

winlogbeat.event_logs:
  - name: Application
  - name: Microsoft-Windows-PowerShell/Operational
  - name: Windows PowerShell
  - name: Microsoft-Windows-WMI-Activity/Operational
  - name: Microsoft-Windows-PowerShell/Admin
    ignore_older: 72h

  - name: System
    ignore_older: 72h

  - name: Security
    processors:
      - script:
          lang: javascript
          id: security
          file: ${path.home}/module/security/config/winlogbeat-security.js

  - name: Microsoft-Windows-Sysmon/Operational
    processors:
      - script:
          lang: javascript
          id: sysmon
          file: ${path.home}/module/sysmon/config/winlogbeat-sysmon.js

#==================== Elasticsearch template settings ==========================

setup.template.settings:
  index.number_of_shards: 3
  #index.codec: best_compression
  #_source.enabled: false


setup.template.enabled: true
setup.template.overwrite: true
setup.template.name: "windows"       
setup.template.pattern: "windows-*" 
setup.dashboards.index: "windows-*"
setup.ilm.enabled: false

#================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
name: "mssql"

# The tags of the shipper are included in their own field with each
# transaction published.
tags: ["192.168.191.80","windows2005 test"]

# Optional fields that you can specify to add additional information to the
# output.
fields:
  source: windows

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  host: "115.238.30.132:5601"

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["115.238.30.132:9200"]

# Configure processors to enhance or manipulate events generated by the beat.

processors:
  - add_host_metadata: ~
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  index: "windows-%{+yyyy.MM.dd}"
復制代碼

(2.1)Winlogbeat specific options 配置實際收集日志模塊

  

(2.2)Elasticsearch template settings ES模板設置

  

索引是3個主分片,副本分片隨集群定義生成,一般是1個主分片對應一個副本分片啦

 這里我們把新建了一個索引模板叫 windows

setup.template.pattern 為哪些名稱的索引會引用該模板

(2.3)General 通用配置(自定義字段)

  

 很重要啊,這個我們采集過來的日志是沒有描述和IP地址的,到時候就算告警,這也不知道啊;

所以我們這里可以盡情加字段什么的;無論是查閱還是告警就是好用的啊

(2.4)kibana

  

 kibana 地址

(2.5)Elasticsearch output 輸出到ES配置

  

 (2.6)【參考】指定數據、日志文件存儲目錄

logging.to_files: true
logging.files:
  path: C:/ProgramData/winlogbeat/Logs
logging.level: info

 

【3】啟動

(3.1)初始化、裝載模板到kibana

在主機上以管理員身份打開 PowerShell 窗口。 我們想要將必要的 Winlogbeat 模板上載到 Elastic 棧中,以進行正確的解析。

在此窗口中,導航到Winlogbeat 文件夾並運行以下命令:

# 切換到下載目錄
d:
cd D:\dba_tools\software\winlogbeat-7.5.1-windows-x86_64
.\winlogbeat.exe setup -e

這個會測試與es、與kibana的連通性與配置是否成功,仔細查看相關信息有沒有 error 等字樣

(3.2)正式啟動

.\winlogbeat.exe -e -c winlogbeat.yml

  

 

會彈出很多信息,畢竟我們 -e 參數就是把信息打印到屏幕上;

初次使用調試的時候很實用

(3.3)通過kibana 查看驗證

先在kibana加上我們這個自定義的 mssql-* 的索引模板

  

 

然后點擊發現

如下圖,我們可以看到一直有數據過來

  

索引也有了;如下圖:

  但我們發現好像有好幾個日期,這是因為保存的文件有好幾個

  

(3.4)把 winlogbeat 封裝成服務啟動(額外)

如下圖,我們可以看到文件夾里有封裝成服務器的PS腳本;

   

 

如下圖,直接執行就安裝好了

   

 

我們啟動一下:

  

 

 

怎么知道數據去哪里了呢?日志怎么看呢?

我們看看 這個安裝腳本 install-service-filebeat.ps1 的內容,如下圖

 

如上圖,同時我們可以看到服務 把數據目錄放到 c:\ProgramData\winlogbeat\data  ,日志目錄也相差不多; 

這個文件夾是隱藏文件夾 直接看看不到,設置了文件夾選項后才能看到,藏的真深

  

  

 

【參考文檔】

 

極易上手搭建自己日志采集服務器分析日志(winlogbeat+Elasticsearch+Kibana):https://blog.csdn.net/UbuntuTouch/article/details/103170326

elastic 中國社區:Beats:如何使用 Winlogbeat:https://blog.csdn.net/UbuntuTouch/article/details/103170326

ELK+Beats實現Windows服務器系統日志監控


免責聲明!

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



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