filebeat 源码编译安装
下载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 GOPATH
already 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