【Logstash】之 从filebeat到logstash

实验:

filebeat 收集日志并发送到logstash


PS : 我好弱啊~

(1)准备


平台:Ubuntu 16.04

filebeat 版本 : 6.3.0 (当前最新)

logstash 版本 : 6.3.0(当前最新)




(2)更改配置


针对 filebeat 中 filebeat.yml 进行配置

此图1的 日志文件 在(3)中配置

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述




(3)添加配置


1. 创建日志文件

创建日志文件 test.log 并 配置下文(内容是从网上copy的)

55.3.244.1 GET /index.html 15824 0.043
55.3.244.1 GET /index.html 15824 0.043

这里写图片描述

2. 创建并配置logstash配置文件

创建 testLogstash.conf
添加下面

input {
    beats {
        port => 5044
    }
}

output {
    stdout {
        codec => rubydebug
    }
}

这里写图片描述




(4)运行


sudo bin/logstash -f testLogstash.conf
这里写图片描述

sudo ./filebeat -e -c filebeat.yml
这里写图片描述




(5)查错


之前testLogstash.conf 配置中 将beats 错打成 beat
然后报了 Failed to connect: dial tcp 127.0.0.1:5044: getsockopt: connection refused

遇到问题可以先去看日志:
这里写图片描述

然后发现:

意思是:没有 beat 这个插件

这里写图片描述




(6)参考资料


http://blog.51cto.com/seekerwolf/2106509
https://doc.yonyoucloud.com/doc/logstash-best-practice-cn/input/stdin.html
https://blog.csdn.net/github_39939645/article/details/78896737
https://jimmysong.io/kubernetes-handbook/practice/app-log-collection.html

猜你喜欢

转载自blog.csdn.net/fanfan4569/article/details/80740414