elasticsearch filebeat使用说明


elasticsearch filebeat使用说明

********************************

filebeat 工作原理

               

filebeat主要由两个组件:prospetor和harverter,

prospector:查找本地文件并为每个文件开启harvestor,支持类型log(默认)、stdin、kafka、redis等

harvestor:读取文件,将文件输出到指定位置

当输出目的地来不及接收数据时,harvestor会放慢读取速度,当输出目的地正常处理数据时,harvestor恢复至正常速度

filebeat会记录文件状态(读取偏移量、文件标识符等)并定期刷新到磁盘的注册文件中,在重新启动的时候会继续发送日志数据;

如果在harvest运行的时候,读取的文件被删除或者重命名,harvest仍会继续读取文件,在harvest关闭的时候释放磁盘空间

如果监控的文件一段时间(close_inactive,默认为5min)没有更新,则关闭harvest;

filebeat会定期扫描文件(scan_frequency,默认为10s),并为新的文件时创建harvest;

 

********************************

filebeat 配置说明

输入设置

#读取日志文件
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/*.log

#控制台输入
filebeat.inputs:
- type: stdin


*************************
输出设置

#输出到elasticsearch
output.elasticsearch:
  hosts: ["host:9200"]
  username: "username"
  password: "password" 

#输出到logstash
output.logstash:
  hosts: ["host:5044"]

#输出到控制台
output.console:
  pretty: true


*************************
kibana仪表盘设置

setup.kibana:
  host: "host:5601"
  username: "username"  
  password: "password"

说明:输入设置中日志路径不会递归搜索,如/var/log/*/*.log,只会匹配/var/log/a/a.log,不会匹配/var/log/b.log、/var/log/c/c/c.log

********************************

docker启动filebeat

下载镜像

docker pull docker.elastic.co/beats/filebeat:7.5.1

配置文件:读取日志文件输出到控制台

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /usr/share/filebeat/logs/*.log

output.console:
  pretty: true

创建容器

docker run -it --net fixed --ip 172.18.0.12 \
-v /usr/elasticsearch/filebeat/config/filebeat2.yml:/usr/share/filebeat/filebeat.yml \
-v /usr/elasticsearch/filebeat/logs:/usr/share/filebeat/logs \
--name filebeat docker.elastic.co/beats/filebeat:7.5.1

控制台输出

          

发布了320 篇原创文章 · 获赞 91 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_43931625/article/details/103913494