在需要采集日志的机器上安装filebeat
下载filebeat
cd /usr/local/
curl -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.6.3-linux-x86_64.tar.gz
但是使用上述curl指令时候会报错Could not resolve host:artifacts.elastic.co
,所以直接在本地机器上使用浏览器访问下述网址下载到本地:https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.6.3-linux-x86_64.tar.gz
使用xshell移动文件到远程机器
使用xshell中xftp中的put
命令将本地下载好的filebeat压缩包传输到远程机器的/usr/local/
文件夹下,并且使用tar -zxvf filebeat-5.6.3-linux-x86_64.tar.gz
解压到/usr/local/
文件夹下。
修改filebeat.yml
cd /usr/local/filebeat-5.6.3-linux-x86_64/ #进入filebeat.yml所在目录
vi filebeat.yml #使用vi编辑器对filebeat.yml文件进行修改
修改后内容如下:
filebeat.prospectors:
- input_type: log
paths:
- /data/hadoop-2.6.5/logs/userlogs/application*/container*/syslog
fields:
service: hdfs
component: datanode
hostname: idsw-dev-03
multiline.pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}
multiline.negate: true
multiline.match: after
#----------------------------- Logstash output --------------------------------
output.logstash:
# The Logstash hosts
hosts: ["10.111.24.89:5044", "10.111.24.90:5044", "10.111.24.91:5044"]
启动filebeat
在/usr/local/filebeat-5.6.3-linux-x86_64
路径下使用命令
./filebeat -e -c filebeat.yml
启动filebeat。