ELK部署文件--filebeat
ELK部署文件--filebeat
1 背景
ELK是三個開源軟體的縮寫,分別表示:Elasticsearch , Logstash, Kibana , 它們都是開源軟體。新增了一個FileBeat,它是一個輕量級的日誌收集處理工具(Agent),Filebeat佔用資源少,適合於在各個伺服器上搜集日誌後傳輸給Logstash。
這是一個最簡單的架構圖:
filebeat ==> logstash ==> elasticsearch ==> kibana
-
資源準備
下載部署包地址:https://www.elastic.co/cn/downloads/past-releases#elasticsearch
注:elk全家桶各個應用版本需一致
-
建立使用者
elk需要用非root使用者部署,因此需要建立一個賬號用於部署
useradd elk
修改目錄的許可權,給elk賦權
chown elk:elk /data/software/elk -R
2 filebeat
Filebeat是用於收集和轉發日誌資料的輕量級傳送工具。Filebeat監視指定的日誌檔案或位置,收集日誌事件,並將它們轉發到Elasticsearch或 Logstash進行索引
filebeat預設埠為5044
2.1 下載安裝
- 解壓安裝包到指定目錄/data/software/elk
tar -vxf filebeat-7.15.2-linux-x86_64 -C /data/software/elk
2.2 配置檔案
- 在filebeat目錄下建立配置檔案
vim itcast.yml
filebeat.inputs: - type: log enabled: true paths: # 配置採集檔案路徑 - /data/logs/devicelog/*/*.log tags: ["device"] # 自定義標籤 fields: # 自定義標籤 service: syslogs fields_under_root: true #預設建立的service標籤在fields下,配置為true後service欄位在根節點下 output.logstash: # 輸出到logstash hosts: ["176.16.9.3:5044"] # 配置為logstash伺服器ip # output.elasticsearch: # 輸出到elasticsearch # hosts: ["176.16.9.3"] # 可通過配置多個- type採集多個目錄資料
2.3 服務部署
在filebeat目錄下啟用:
nohup ./filebeat -e -c itcast.yml > filebeat.log &
輸出日誌在filebeat.log目錄下
檢查服務:
ps -ef | grep filebeat
2.4 基本命令
-
export
export命令可把資訊輸出到終端,在終端中快速檢視配置、索引模板和ILM策略等內容
-
輸出配置內容
在filebeat資料夾下檢視itcast.yml檔案:
./filebeat export config -c itcast.yml
-
輸出索引模板
./filebeat export template
也可以把資訊輸出到指定資料夾(/data/template)下
./filebeat export template --dir /data/template
-
輸出索引生命週期管理策略(可通過--dir指定輸出檔案中)
./filebeat export ilm-policy
-
-
modules
管理配置模組,該模組可以設定使用或者取消使用特定的模組配置
- 檢視模組配置
./filebeat modules list
- 使用模組配置
./filebeat modules enable (模組名稱)
- 取消使用模組配置
./filebeat modules disable (模組名稱)
- 檢視模組配置
-
run
執行filebeat模組,指定特定的執行規則
-
指定CPU資料檔案
-cpuprofile /data/file
-
指定記憶體資料檔案
-memprofile /data/file
-
啟用指定選擇器的除錯
-d "publisher"
-
指定配置檔案
-c ./conf.yml
指定自定義配置檔案,不指定預設指定為filebeat.yml
-
-
覆蓋配置引數
覆蓋配置檔案中輸出地址,可以作用於正在執行的filebeat,並且不修改配置檔案,可以指定多個配置
./filebeat -E "output.logstash.hosts=['http://localhost:5044']"
詳細命令資訊可參考:https://www.elastic.co/guide/en/beats/filebeat/current/command-line-options.html#global-flags
本文來自部落格園,作者:liu_kx,轉載請註明原文連結:https://www.cnblogs.com/liukx/p/15711515.html