tester-technology

filebeat安装与使用

2019-01-03  本文已影响12人  testerzhang

下载

官网下载

这里以6.4.0版本为例

$ wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.4.0-linux-x86_64.tar.gz

安装

$ tar zxf filebeat-6.4.0-linux-x86_64.tar.gz
$ cd filebeat-6.4.0-linux-x86_64

配置

$ vi filebeat.yml

filebeat.inputs:
- type: log

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

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /tmp/logs/test.log

  fields:
    app_id: query_oalog_1
    log_type: api-hub

  multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}'

  # Defines if the pattern set under pattern should be negated or not. Default is false.
  multiline.negate: true

  # Match can be set to "after" or "before". It is used to define if lines should be append to a pattern
  # that was (not) matched before or after or as long as a pattern is not matched based on negate.
  # Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
  multiline.match: after
  
#加载不同的模板
setup.template.name: "filebeat"
setup.template.pattern: "filebeat-*"
setup.template.settings:
  index.number_of_shards: 3
 
#写入搜索引擎
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["10.10.10.10:9200"]
  #默认情况下,Filebeat写事件到名为filebeat-6.4.0-yyyy.MM.dd的索引,其中yyyy.MM.dd是事件被索引的日期。为了用一个不同的名字,你可以在Elasticsearch输出中设置index选项。
  index: "%{[fields.log_type]}-%{[beat.version]}-%{+yyyy.MM.dd}"

主要配置项说明:

启动

$ nohup ./filebeat -e -c filebeat.yml > filebeat.log &
上一篇 下一篇

猜你喜欢

热点阅读