1.安装filebeat

  1. [root@client ~]# wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.2.0-linux-x86_64.tar.gz
  2. [root@client ~]# tar zxvf filebeat-7.2.0-linux-x86_64.tar.gz
  3. [root@client ~]# mv filebeat-7.2.0-linux-x86_64 /usr/local/filebeat
  4. [root@client ~]# cd /usr/local/filebeat
  5. [root@client ~]# cp filebeat.yml filebeat.yml.bak
  6. # 修改配置文件(需要指定日志path和服务器ip)
  7. [root@client ~]# cat /usr/local/filebeat/filebeat.yml | grep -v "^$" |grep -v "^#" |grep -v "#"
  8. filebeat.inputs:
  9. - type: log
  10. enabled: true
  11. paths:
  12. - /usr/local/seektruth/logs/aeonlife_prod/info.*.log
  13. # exclude_files: [".gz$"] : #移除这个目录下面相关gz结尾的文件
  14. # exclude_lines: ["^DBG"]: #表示移除什么样的结尾的行。
  15. fields:
  16. appname: online-aeonlife-info-log
  17. - type: log
  18. enabled: true
  19. paths:
  20. - /usr/local/seektruth/logs/aeonlife_prod/access.*.log
  21. fields:
  22. appname: online-aeonlife-access-log
  23. - type: log
  24. enabled: true
  25. paths:
  26. - /usr/local/seektruth/logs/aeonlife_prod/error.*.log
  27. fields:
  28. appname: online-aeonlife-error-log
  29. filebeat.config.modules:
  30. path: ${path.config}/modules.d/*.yml
  31. reload.enabled: false
  32. setup.template.settings:
  33. index.number_of_shards: 1
  34. setup.kibana:
  35. #----------------------------- Logstash output --------------------------------
  36. output.logstash:
  37. hosts: ["192.168.3.3:5044"]
  38. processors:
  39. - add_host_metadata: ~
  40. - add_cloud_metadata: ~
  41. #----------------------------- kafka output --------------------------------
  42. #output.kafka:
  43. # enabled: true
  44. # hosts: ["192.168.3.3:9092"]
  45. # topic表示filebeat将数据输出到topic为sparksys-log的主题下
  46. # topic: sparksys-log

2.启动服务

  1. [root@client ~]# cd /usr/local/filebeat
  2. [root@client ~]# nohup ./filebeat &
  3. # 注意:filebeat没有监听端口,主要看日志和进程
  4. [root@client filebeat]# ps aux |grep filebeat
  5. root 3819 0.0 0.5 25944 11304 ? Ssl 715 0:17 /usr/share/filebeat/bin/filebeat -c /etc/filebeat/filebeat.yml -path.home /usr/share/filebeat -path.config /etc/filebeat -path.data /var/lib/filebeat -path.logs /var/log/filebeat
  6. root 3879 0.0 0.0 112664 972 pts/1 S+ 15:29 0:00 grep --color=auto filebeat
  7. root 26223 0.0 0.3 17488 7188 pts/1 Sl 15:00 0:00 ./filebeat