centos7搭建filebeat

filebeat的环境搭建

cd /home/elk
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.2.4-linux-x86_64.tar.gz
tar -zvxf filebeat-6.2.4-linux-x86_64.tar.gz
mv filebeat-6.2.4-linux-x86_64 filebeat

修改配置文件

filebeat.prospectors:
- input_type: log
  paths:
    - /opt/dev/log/claimzuul/*.log
  document_type: "claimzuul" # 定义写入 ES 时的 _type 值
  multiline:
    #pattern: '^\s*(\d{4}|\d{2})\-(\d{2}|[a-zA-Z]{3})\-(\d{2}|\d{4})'   # 指定匹配的表达式(匹配以 2017-11-15 08:04:23:889 时间格式开头的字符串)
    pattern: '^\s*("{)'                         # 指定匹配的表达式(匹配以 "{ 开头的字符串)
    negate: true                                # 是否匹配到
    match: after                                # 合并到上一行的末尾
    max_lines: 1000                             # 最大的行数
    timeout: 30s                                # 如果在规定的时候没有新的日志事件就不等待后面的日志
  fields:
    logsource: localhost
    logtype: claimzuul

#- input_type: log
 # paths:
  #  - /var/log/messages
    #- /var/log/*.log
  #document_type: "syslog" # 定义写入 ES 时的 _type 值
  #fields:
   # logsource: localhost
    #logtype: syslog

#output.elasticsearch:
#  hosts: ["localhost:9200"]

output.logstash:
  hosts: ["localhost:8082"]

启动

nohup ./filebeat -e -c filebeat.yml &

借鉴https://www.cnblogs.com/xishuai/p/elk-elasticsearch-kibana-logstash-filebeat-log4j2.html

猜你喜欢

转载自www.cnblogs.com/mutong1228/p/10186802.html