Windows下日誌蒐集系統EFK的初步嘗試
業界通用的日誌數據管理解決方案 - 它主要包括 Elasticsearch 、 Logstash 和 Kibana 三個系統。
文中涉及的 ELK stack 版本是:
Elasticsearch 7.6
Logstash 7.6 (這裏不用)
Kibana 7.6
Filebeat 7.6
安裝
從elastic官網下載各個組件最新版本,地址爲
kibana-7.6.2
elasticsearch-7.6.2
filebeat-7.6.2
下載解壓
配置運行
修改elasticserach.yml配置文件
- network.host: 0.0.0.0 (方便測試配置爲0.0.0.0需要配置discovery.type爲single-node )
- discovery.type: single-node
> .\bin\elasticsearch.bat
修改kibana.yml配置文件
- server.host: "0.0.0.0"
> .\bin\kibana.bat
配置filebeat.yml
在需要採集日誌的機器上安裝filebeat
-
配置input
filebeat.inputs: - type: log enabled: true paths: - C:\Users\AppData\Roaming\xxx\*.log tags: ["animation"] fields: source: animation - type: log enabled: true paths: - C:\Users\AppData\Roaming\yyy\*.log tags: ["picture"] fields: source: picture
-
配置output
output.elasticsearch: hosts: ["192.168.0.1:9200"] index: "renderbus-log-%{[fields.source]}-*" indices: - index: "log-animation-%{+yyyy.MM.dd}" when.equals: fields: source: "animation" - index: "log-picture-%{+yyyy.MM.dd}" when.equals: fields: source: "picture" #output.logstash: # use logstash #hosts: ["192.168.0.1:5044"]
-
配置kibana
setup.kibana: host: "192.168.0.1:5601"
-
配置模板
setup.template.name: "renderbus-log" setup.template.pattern: 'renderbus-log-*' setup.template.enabled: true setup.template.overwrite: true
-
配置索引生命週期管理(7.6需要)(ilm => index-lifecycle-management)
setup.ilm.enabled: false
-
.\filebeat.exe -e
查看
瀏覽器訪問 http://192.168.0.1:5601
Management > Index patterns > Create index pattern > …
參考引用
elastic-stack
Elasticsearch Reference
Kibana Guide
Filebeat Reference
filebeat-input-log
從ELK到EFK,日誌系統的高級玩法兒
Kibana Tutorial
Filebeat自定義索引 && 多output過濾
Adding more fields to Filebeat