上面一篇已經講解了如何基於docker構建ELK環境。接下來記錄一下,在ELK的基礎上新增filebeat的方法。
1、下載filebeat的軟件包
在這個例子中我們用的是目前filebeat的最新版本即7.4.2,下載地址爲://download.csdn.net/download/yangqinfeng1121/11975165
把filebeat放到要抽取日誌的服務上,並解壓開
tar zvxf filebeat-7.4.2-linux-x86_64.tar.gz
2、安裝filebeat
1、進入到filebeat文件夾下,修改filebeat.yml的配置文件
- type: log
# Change to true to enable this input configuration.
enabled: true
# Paths that should be crawled and fetched. Glob based paths.
paths:
#抽取日誌的地址
- /data/springboot/logs/jdcaisher/app/*.log
# 日誌多行合併採集
multiline.pattern: '^\['
multiline.negate: true
multiline.match: after
#tag名稱
tags: ["jdcaisher"]
# 這個文件記錄日誌讀取的位置,如果容器重啓,可以從記錄的位置開始取日誌
#registry_file: /usr/share/filebeat/data/registry
#-------------------------- Elasticsearch output ------------------------------
#把輸出的ES的部分註釋
#output.elasticsearch:
# Array of hosts to connect to.
# hosts: ["localhost:9200"]
#----------------------------- Logstash output --------------------------------
#向自己的logstash發送日誌
output.logstash:
# The Logstash hosts
hosts: ["172.16.0.39:5044"]
3、啓動filebeat
後臺守護進程
nohup ./filebeat > /dev/null 2>&1 &
4、這時正在kibana上就能看到filebeat抽取過來的日誌了