使用filebeat替换logstash

2017-01-11  本文已影响0人  梦想做小猿

说明

logstash 功能虽然强大,但是基于ruby的配置语法、依赖jdk、消耗系统资源等弊端,使得考虑其他方式来替换logstash,filebeat则是一个完美的替代者

安装

官网:https://www.elastic.co/downloads/beats/filebeat

#下载
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.1.1-linux-x86_64.tar.gz
#解压安装
tar zxvf filebeat-5.1.1-linux-x86_64.tar.gz
#启动
./filebeat -e -c conffile.yaml
# -e 输出日志
# -c 指定配置文件

实例

filebeat.prospectors:
 - input_type: log
    paths: /var/log/nginx/access.log

 output.console:
    enabled: true

配置解释:
filebeat.prospectors: 定义数据原型
input_type: log,指定数据原型为log类型

paths: 指定日志路径
output.console: 指定控制台标准输出

nginx日志实例

nginx 日志格式已配置成json字符串格式:

{"@timestamp":"2017-01-11T16:38:42+08:00","host":"172.16.11.193","clientip":"172.16.11.239","size":"body_bytes_sent","responsetime":0.000,"upstreamtime":"-","upstreamhost":"-","http_host":"172.16.11.193","url":"/index.html","xff":"-","referer":"-","agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36","status":"200"}

filebeat配置:

filebeat.prospectors:
- input_type: log
  paths: /var/log/nginx/access.log
  json.message_key:

output.elasticsearch:
  hosts: ["172.16.11.199"]
  index: "filebeat-nginx-%{+yyyy.MM.dd}"

配置详解:

详细配置可查看filebeat解压自带的filebeat.full.yml文件

上一篇下一篇

猜你喜欢

热点阅读