下載filebeat源碼(6.2.3)下載地址:鏈接: https://pan.baidu.com/s/1cPR7-xlQJuYZ77uaUpfSpQ 提取碼: k77u
github下載地址:https://github.com/elastic/beats
github下載過程如下圖所示


編譯步驟,見官網文檔,查找如下圖所示:
在docs目錄下有devguide目錄,在該目錄下有個contributing.asciidoc文檔

文檔中Setting Up Your Dev Environment章節
內容:
The Beats are Go programs, so install the latest version of golang if you don’t have it already. The current Go version used for development is Golang {go-version}.
The location where you clone is important. Please clone under the source directory of your GOPATH. If you don’t have GOPATHalready set, you can simply set it to the go directory in your home (export GOPATH=$HOME/go).
mkdir -p ${GOPATH}/src/github.com/elastic cd ${GOPATH}/src/github.com/elastic git clone https://github.com/elastic/beats.git
|
Note
|
If you have multiple go paths, use ${GOPATH%%:*} instead of ${GOPATH}. |
可以看出,filebeat編譯,需要go語言環境,6.2.3用的go語言是1.9.2,其按照步驟參考:https://www.cnblogs.com/dyh004/p/9669406.html
Then you can compile a particular Beat by using the Makefile. For example, for Packetbeat:(文檔中,以packetbeat為例進行編譯),我們要編譯的是filebeat
cd beats/filetbeat make
make之后,會在filebeat目錄下生產filebeat可執行文件,如圖

編譯配置filebeat.yml文件
1.將enable 設置為true
2.paths設置指定的log文件的輸出目錄
3.添加fields字段,通過ip添加索引名稱,名稱設置為自己的姓名加ip地址便於區分,索引名稱不能包括大寫。
4.將oupput模塊的配置elastic output,或者logstash
5.filebeat啟動:
./filebeat -e -c filebeat.yml -d "Publish"
-e: Log to stderr and disable syslog/file output
-c: Configuration file, relative to path.config (default "filebeat.yml")
-d: Enable certain debug selectors
