部署FileBeat采集日志发送到Kafka集群服务器

为什么要使用FileBeat

Logstash功能虽然强大,但是他依赖java,在数据量大的时候,Logstash进程会消耗过多的系统资源,这将严重影响业务系统的性能,而Filebeat就是一个完美的代替者,filebeat是Beat成员之一,基于Go语言开发,没有任何依赖,配置文件简单,格式明了,同时,Filebeat比Logstash更加轻量级所以占用系统资源极少,非常适合安装到生产机器上。

FileBeat概述

Filebeat是用于转发和集中日志数据的轻量级发送器。Filebeat作为代理安装在您的服务器上,监视您指定的日志文件或位置,收集日志事件,并将它们转发到弹性搜索或者Logstash用于索引。

Filebeat是这样工作的:当您启动Filebeat时,它会启动一个或多个输入,这些输入会在您为日志数据指定的位置中查找。对于Filebeat找到的每个日志,Filebeat都会启动一个采集器。每个收集器读取一个新内容的日志,并将新的日志数据发送到libbeat,后者聚合事件并将聚合的数据发送到您为Filebeat配置的输出。

Beats design

FileBeat安装

#由于Filebeat基于Go语言开发,无其他依赖,因而安装非常简单,可以从elastic官网https://www.elastic.co/downloads/beats/filebeat/获取Filebeat的安装包

#安装wget
yum install wget
#切换目录
cd /usr/local/
#下载Filebeat
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.13.4-linux-x86_64.tar.gz
#解压缩   由于是下载的二进制Filebeat文件 解压即安装
tar -xzvf filebeat-7.17.9-linux-x86_64.tar.gz -C /usr/local
#更换名称
mv filebeat-7.17.9-linux-x86_64 filebeat
#到此安装完成

简单介绍FileBeat目录作用

-rw-r--r--  1 root root        41 1月  31  2023 .build_hash.txt		
-rw-r--r--  1 root root   3781373 1月  31  2023 fields.yml
-rwxr-xr-x  1 root root 112216160 1月  31  2023 filebeat*		#可执行二进制文件
-rw-r--r--  1 root root    170372 1月  31  2023 filebeat.reference.yml
-rw-------  1 root root      8348 1月  31  2023 filebeat.yml		#配置文件
drwxr-xr-x  3 root root      4096 1月  31  2023 kibana/        
-rw-r--r--  1 root root     13675 1月  31  2023 LICENSE.txt
drwxr-xr-x 76 root root      4096 1月  31  2023 module/          
drwxr-xr-x  2 root root      4096 1月  31  2023 modules.d/	     #模块文件 调用模块代码都在这个里面
-rw-r--r--  1 root root   2058190 1月  31  2023 NOTICE.txt
-rw-r--r--  1 root root       814 1月  31  2023 README.md

配置filebeat.yml配置文件

vim filebeat.yml
#########filebeat.yml##########################
###################### Filebeat Configuration Example #########################

# This file is an example configuration file highlighting only the most common
# options. The filebeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/filebeat/index.html

# For more available modules and options, please see the filebeat.reference.yml sample
# configuration file.

# ============================== Filebeat inputs ===============================

filebeat.inputs:

# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.

# filestream is an input for collecting log messages from files.
#
# hk-system
- type: log

  # Unique ID among all inputs, an ID is required.
  id: hk-system-error

  # Change to true to enable this input configuration.
  enabled: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /home/ebc/system/hk-system/error.log
 #   - /home/ebc/system/hk-system/input*.log
  fields:
    log_topic: hk-system-error
    #- /var/log/*.log
    #- c:\programdata\elasticsearch\logs\*
#配置从哪里取日志 paths   存到kafka那个topic里面  fields
- type: log
  id: hk-system-info
  enabled: true
  paths:
    - /home/ebc/system/hk-system/info.log
  fields:
    log_topic: hk-system-info

- type: log
  id: hk-settlement-error
  enabled: true
  paths:
    - /home/ebc/settlement/hk-settlement/error.log
  fields:
    log_topic: hk
  • 10
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值