1、概述

filebeat使用go语言开发,轻量级、高效。主要由两个组件构成:prospector和harvesters。

Harvesters负责进行单个文件的内容收集,在运行过程中,每一个Harvester会对一个文件逐行进行内容读取,并且把读写到的内容发送到配置的output中。

Prospector负责管理Harvsters,并且找到所有需要进行读取的数据源。如果input type配置的是log类型,Prospector将会去配置度路径下查找所有能匹配上的文件,然后为每一个文件创建一个Harvster。

2、下载

https://www.elastic.co/cn/downloads/beats/filebeat

3、安装

解压即可,开包即用。方便升级推荐使用tar包。

参考官网:https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-installation.html

4、配置文件

############################# input #########################################
filebeat.prospectors:
# 采集系统日志
- input_type: log
paths: /var/log/messages
paths: /var/log/cron
document_type: "messages" # 采集MySQL慢日志,这里用到了多行模式
- input_type: log
paths: /data/mysql/data/slow.log
document_type: mysql_slow_log
multiline:
pattern: "^# User@Host: "
negate: true
what: "previous"
charset: "ISO-8859-1"
match: after # 采集web日志
- input_type: log
paths: /data/wwwlogs/access_*.log
document_type: "web_access_log" # 规避数据热点的优化参数:
# 积累1024条消息才上报
spool_size: 1024
# 或者空闲5s上报
idle_timeout: "5s" #这里配置下name这个字段为本机IP,用于logstash里面将这个值赋给一些拿不到主机IP的数据,比如慢日志
name: 10.x.x.x ############################# Kafka #########################################
output.kafka:
# initial brokers for reading cluster metadata
hosts: ["x.x.x.1:9092","x.x.x.2:9092","x.x.x.3:9092"]
# message topic selection + partitioning
topic: '%{[type]}'
flush_interval: 1s
partition.round_robin:
reachable_only: false
required_acks: 1
compression: gzip
max_message_bytes: 1000000 ############################# Logging #########################################
logging.level: info
logging.to_files: true
logging.to_syslog: false
logging.files:
path: /data/filebeat/logs
name: filebeat.log
keepfiles: 7 5、output几种类型
本例使用的是kafka,还可以输出到logstash、redis、elsticsearch等
1)logstash
output.logstash:
  # The Logstash hosts
hosts: ["ip:5044"]

2)redis
参考:https://www.elastic.co/guide/en/beats/filebeat/current/redis-output.html
output.redis:
hosts: ["localhost"]
password: "my_password"
key: "filebeat"
db: 0
timeout: 5 3)elasticsearch
参考:https://www.elastic.co/guide/en/beats/filebeat/current/elasticsearch-output.html
output.elasticsearch:
hosts: ["http://localhost:9200"]
username: "admin"
password: "s3cr3t" 6、elasticsearch加载filebeat的模板
#curl -XPUT -H 'Content-Type: application/json' http://localhost:9200/_template/filebeat-6.1.0 -d@/etc/filebeat/filebeat.template.json filebeat之docker日志json报错处理:
问题:
使用Filebeats针对docker日志进行收集,docker日志默认是JSON格式,日志每个开头都有 {"log:"的字样,所以我在filebeats中加入了 json.message_key: '{"log":"'。但是filebeats 日志会报错,输出  
ERR Error decoding JSON: invalid character 'J' looking for beginning of value  prospectors:
        -
          paths:
            - /var/log/containers/*.log
          document_type: kube-logs
          ignore_older: 24h
          symlinks: true
          json:
            keys_under_root: true
            add_error_key: true
            message_key: log

ELK之filebeat的更多相关文章

  1. ELK + Kafka + Filebeat

    ELK + Kafka + Filebeat学习 https://blog.csdn.net/qq_21383435/article/details/79463832 https://blog.csd ...

  2. 关于elk中filebeat定义好日志输出,但是redis里面却没有输出内容的问题

    这两天在搞elk的时候,filebeat中指定输出日志至Broker(此处Broker采用redis作为缓存),但是redis中却没有内容,所以就开始排查来 filebeat采用RPM安装的方式来的. ...

  3. 超烂的ELK之filebeat读取【已解决】

    搞了无数次的filebeat-->logstash今天栽了跟头 filebeat在读取如下文件的时候,openchgw.log 软连接speechgw.log.20170703183729文件 ...

  4. [elk]logstash&filebeat常用语句

    filebeat安装dashboard 参考: https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-getting-star ...

  5. Ubuntu 16.04安装Elasticsearch,Logstash和Kibana(ELK)Filebeat

    https://www.howtoing.com/how-to-install-elasticsearch-logstash-and-kibana-elk-stack-on-ubuntu-16-04 ...

  6. ELK之filebeat收集多类型日志

    1.IP规划 10.0.0.33:filebeat+tomcat,filebeat收集系统日志.tomcat日志发送到logstash 10.0.0.32:logstash,将日志写入reids(in ...

  7. ELK整合Filebeat监控nginx日志

    ELK 日志分析 1. 为什么用到 ELK 一般我们需要进行日志分析场景:直接在日志文件中 grep. awk 就可以获得自己想要的信息.但在规模较大的场景中,此方法效率低下,面临问题包括日志量太大如 ...

  8. ELK+kafka+filebeat搭建生产ELFK集群

    文章原文 ELK 架构介绍 集群服务版本 服务 版本 java 1.8.0_221 elasticsearch 7.10.1 filebeat 7.10.1 kibana 7.10.1 logstas ...

  9. ELK 使用filebeat替代Logstash收集日志

    使用beats采集日志 之前也介绍过beats是ELK体系中新增的一个工具,它属于一个轻量的日志采集器,以上我们使用的日志采集工具是logstash,但是logstash占用的资源比较大,没有beat ...

  10. ELK之filebeat、logstash多个topic配置

    启动多个进程收集日志.直接output到kafka,output到不同的topiccat filebeat.ymlfilebeat.prospectors:- input_type: log path ...

随机推荐

  1. 5、Makefile基础知识汇总(转自陈皓总述)

    一.Makefile里有什么? Makefile里主要包含了五个东西:显式规则.隐晦规则.变量定义.文件指示和注释. 1.显式规则.显式规则说明了,如何生成一个或多的的目标文件.这是由Makefile ...

  2. Form表单中的action提交路径问题

    Form表单中的action提交路径问题 Form表单action属性和method属性的一些问题: 我遇到的是Form表单提交到servelet处理时遇到的问题:(1)<form name=& ...

  3. panda

    这个项目很有意思,麻雀虽小五脏俱全. 页面使用rem和media query来设置字体和元素宽高image居中需要用到position 后端mysql使用阿里云的rds:nodejs的mysql模块的 ...

  4. 在CentOS上安装GITLAB

    为什么要用gitlab? 方便地管理项目,设置用户权限. 参考 https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md 步 ...

  5. @requestParamore与@pathvariable的区别

    http://localhost:8080/Springmvc/user/page.do?pageSize=3&pageNow=2 你可以把这地址分开理解,其中问号前半部分:http://lo ...

  6. 搭建一台deeplearning的服务器

    在计算机时代的早期,一名极客的满足感很大程度上来源于能DIY一台机器.到了深度学习的时代,前面那句话仍然是对的. 缘起在2013年,MIT科技评论将深度学习列为当年十大科技突破之首.其原因在于,模型有 ...

  7. 合成的默认构造函数定义为delete的一种情况(针对C++11标准)

    1. 默认初始化 如果定义变量时没有指定初值,则变量会被默认初始化,此时变量被赋予了"默认值". 对于类类型的变量来说,初始化都是依靠构造函数来完成的.因此,即使定义某个类的变量( ...

  8. CopyOnWriteArrayList源码解析(2)

    此文已由作者赵计刚授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 5.删除元素 public boolean remove(Object o) 使用方法: list.remo ...

  9. 【062新题】OCP 12c 062出现大量新题-15

    choose one In your Oracle 12c database, you plan to execute the command: SQL> CREATE TABLESPACE t ...

  10. 微信赌场——H5棋牌游戏渗透之旅

    i春秋作家:F0rmat 0x01 前言 本来不想发的,涉及太多利益了,这些棋牌游戏的源码最高能卖到几万.开发起来不比一个商场程序难.最近又太忙了,没时间去做代码审计的文章了,但一不小心又抢了个运气王 ...