centos7安装filebeat

2019-04-15  本文已影响0人  普度众生的面瘫青年

Q1: 既然filebeat可以直接把数据发送到es,为什么还要经过logstash呢?

Q2: 既然logstash也可以从文件收集数据,为什么还要使用filebeat呢?

logstash和filebeat简单对比
安装logstash
搭建elasticSearch

下载

官方下载链接

安装

tar -xf filebeat-7.0.0-linux-x86_64.tar.gz
mv filebeat-7.0.0-linux-x86_64 /usr/local/filebeat

配置filebeat

注意,filebeat6.x以后不允许有多个output了,所以配置文件中的output只能选择一个

vi /usr/local/filebeat/filebeat.yml
filebeat.inputs:
  - type: log
    enabled: true
    paths:
      - /var/log/*.log

直连kibana
setup.kibana:
  host: "172.17.2.89:5601"

直连es
output.elasticsearch:
  hosts: ["172.17.2.89:9200"]

连接logstash  5044是logstash配置文件中input.beats.port的配置值
output.logstash:
  hosts: ["172.17.2.89:5044"]

安装httpd用于测试

每次访问localhost,都会在 /var/log/httpd/access_log文件中追加一条日志

yum install httpd
echo "hello world" > /var/www/html/index.html
systemctl start httpd 启动httpd
systemctl enable httpd 设置开机自启动

检查

后台启动filebeat

./usr/local/filebeat/filebeat -c filebeat.yml &

每次执行以上命令,都会向 /var/log/httpd/access_log文件中追加一条日志

curl localhost

该日志将被filebeat收集到elasticsearch或logstash

到kibana创建一个filebeat*的index pattern
即可在discover中看到access_log中的每条日志

上一篇 下一篇

猜你喜欢

热点阅读