ELK Stack之filebeat使用

来源:互联网 发布:淘宝关闭货到付款流程 编辑:程序博客网 时间:2024/06/06 10:54

         ELK平台的传统用法,logstash采集对于分布式不是很支持,一般有使用forwarder的.

          filebeat基础用法: filebeat作为轻量采集端,收集数据传送给logstash ;logstash接收并输出到es中去

         优势:轻量级的收集,支持分布式;最终master仅需少数几台即可

        多看看filebeat.yml注释说明,看看官网上的讨论就差不多能使用了,也都是些基础的东西。感觉最深的就是能看进去英文文档了,各种看,确实看多了,做的也就越来越快了。

        我这里都用的老版本,logstash1.5.6  filebeats1.0.0   当时logstash1.5.0版本要装logstash-input-beats插件,直接./plugin install各种问题,最后不了了之,用了1.5.6版本,自带了beats input,也能与老版本es1.6.0配合。

    注释: filebeat1.1.1以上版本支持 —— multiline,在yml文件中就能使用了,这样避免了只能在ligstash中port中使用 codec,而导致多文件输入时所有文件都被迫多行整合到单行。

例如:

   multiline: 
       pattern: "^# User@Host:"    (以User@Host开头文件,这是mysql慢日志查询中开头)
       negate: true
       match: after


      记录: bin/plugin  list   得到所有可使用插件命令

                 bin/plugin install logstash-input-update 


      filebeats简单配置内容:

 

filebeat:  prospectors:    # Each - is a prospector. Below are the prospector specific configurations    -      paths:      #  - /var/log/*.log        - E:\ELK\test_log\*_call.log      #  - /home/cuixuange/公共/standardlog/*_call.log      input_type: log      document_type: beatscall    -      paths:      #  - /var/log/*.log        - E:\ELK\test_log\*_cpu.log      #  - /home/cuixuange/公共/standardlog/*_cpu.log      input_type: log      document_type: beatscpu    -      paths:      #  - /var/log/*.log        - E:\ELK\test_log\*_disk.log      #  - /home/cuixuange/公共/standardlog/*_disk.log      input_type: log      document_type: beatsdisk

   这里说明一下:1.0版本  document_type就是logstash 中的type,所以不同文档名字的通过documen_type区分

output:  ### Logstash as output  logstash:    # The Logstash hosts    hosts: ["XXXXXXXXXX:5044"]    # Number of workers per Logstash host.    worker: 2


shipper:  # The name of the shipper that publishes the network data. It can be used to group  # all the transactions sent by a single shipper in the web interface.  # If this options is not defined, the hostname is used.  name: beats1

启动过程·:

inux=     ./filebeat -e -c ./filebeat.yml

  windows下面使用ps,就是powershell,win7以上版本自带    w11111111111111111111111111111111

PS > cd '你的目录'PS 你的目录> .\install-service-filebeat.ps1

这里报错,该系统无法执行脚本等等,这时输入命令set-ExecutionPolicy RemoteSigned 即可; 这里也需要管理员权限运行,这是因为您第一次使用Powershell,默认不执行脚本的.


开始启动filebeat

PS 你的目录> Start-Service filebeat

关闭的话:可以重新执行install,里面ps1中有判断,如果有启动的服务则删除; 也可以可以调用删除uninstall-service-filebeat.ps1   可能会报错:脚本未经过数字签名,无法执行。这时将文件点击右键,选择解除锁定,即可。

这些数字签名内容在  get-help about_signing命令都有包含.

或者类似于linux这样:::::


注释:我自己测试的时候复制文件到指定文件夹的时候发现总是filebeat都不进去数据,不能正常发送数据(linux没事,每次都会发送出去;在windows测试的时候发现,

复制到文件夹中时候还得再改变文件内容windows才认为有文件更新————————也许只有我有这问题?——————这意味着当一个新文件建立的时候并不能立即把第一条数据

发送给logstah只有当本文件后续更新的时候才会把之前的内容进行发送————————linux、windows都有一个registry文件进行保存上一次tail的位置)

最后多path路径还是可以了:





一些很有用的博客链接:

         ELK讨论链接

         ELK Stack with beats搭建

        官网安装配置说明

         运维生存时间


0 0
原创粉丝点击