filebeat 是基于原先 logstash-forwarder 的源码改造出来的。换句话说:filebeat 就是新版的 logstash-forwarder,也会是 Elastic Stack 在 shipper 端的第一选择。
1.安装
到官网下载安装包
https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.6.0-windows-x86_64.zip
解压好后放到Client服务器的C:Program file下
使用系统powershell(2008系统自带powershell,低于2008的机器就要自己安装了)进行安装,安装完成会生成一个名为filebeat的服务。
PS C:Program Filesfilebeat> .install-service-filebeat.ps1 无法加载文件 C:Program Filesfilebeatinstall-service-filebeat.ps1,因为在此系统中禁止执行脚本。有关详细信 get-help about_signing"。 所在位置 行:1 字符: 31 + .install-service-filebeat.ps1 <<<< + CategoryInfo : NotSpecified: (:) [], PSSecurityException + FullyQualifiedErrorId : RuntimeException
安装会有报错,由于powershell是不允许执行任何可执行脚本的,所以这里需要调整策略,关于报错的具体信息了解可以跳到这里http://www.cnblogs.com/zhaozhan/archive/2012/06/01/2529384.html。
PS C:Program Filesfilebeat> PowerShell.exe -ExecutionPolicy RemoteSigned -File .install-service-filebeat. Status Name DisplayName ------ ---- ----------- Stopped filebeat filebeat PS C:Program Filesfilebeat>
安装完成。
2.配置:filebeat.yml
配置input
filebeat.prospectors:
- input_type: log #输入的数据类型
paths:
- D:logsLogFilesW3SVC4*.log #文件路径
tail_files: true #是否从文件末尾开始读取
encoding: utf-8 #日志文件编码 document_type: IIS_LOG #自定义文件字段,根据你的输入数据命名。 fields_under_root: true #新增字段是否置顶。 fields: host_ip: x.x.x.x #新增IP字段,把Client的IP带过去。
配置output:
#----------------------------- Logstash output -------------------------------- output.logstash: #输出到logstatsh # The Logstash hosts hosts: ["x.x.x.x:5044"] #logstash的IP端口
完成简单的配置, .filebeat.exe -e -c .filebeat.yml --configtest 进行配置文件测试,显示Config OK就完成了,注意配置文件对缩进要求很严格,尽量不要使用自带记事本进行编辑,编辑器的话notepad++是不错的选择。