美文网首页
Linux 安装 filebeat 对接 elasticsear

Linux 安装 filebeat 对接 elasticsear

作者: SlowGO | 来源:发表于2018-11-20 18:45 被阅读6次

下载解压

https://www.elastic.co/cn/downloads/beats/filebeat

配置

新建配置文件:

cp filebeat.yml filebeat.center.yml

修改 filebeat.center.yml 中主要的3个地方:

// 第1个地方
filebeat.inputs:

- type: log

  # 改为 true
  enabled: true

  # 监控的日志路径
  paths:
    - /data/log/*

// 第2个地方(如果需要多行合并,就配置  multiline,各项含义在后面解释)
  multiline.pattern: '^\d+.*$' 
  multiline.negate: true
  multiline.match: after
  multiline.timeout: 5s

// 第3个地方
#=========== Elasticsearch template setting ============
# 添加模板配置
setup.template.name: "center-%{+yyyy.MM.dd}"
setup.template.pattern: "center-*"

// 第4个地方
output.elasticsearch:
  # ES 地址
  hosts: ["12.18.84.12:9200"]
  # 设置索引
  index: "center-%{+yyyy.MM.dd}"

启动

nohup ./filebeat -e -c filebeat.center.yml -d "publish" > out_center.file 2>&1 &

检查

查看启动日志:

tail -f out_center.file

ES 中查看索引是否出现:

curl '12.18.84.12:9200/_cat/indices?v'

multiline 配置说明

multiline 各项含义:

    # 日志行的正则匹配,这里是以数字开头的
    pattern: '^\d+.*$' 

    # negate 是否定的意思,就是合并匹配的还是不匹配的
    # true 表示把不匹配pattern的行合并到上一行
    # false 表示把匹配pattern的行合并到上一行
    negate: true

    # after 或 before,合并到上一行的末尾或开头
    match: after

    # 合并过程的超时时间,防止合并时间过长导致卡死
    timeout: 5s

相关文章

网友评论

      本文标题:Linux 安装 filebeat 对接 elasticsear

      本文链接:https://www.haomeiwen.com/subject/zvnxqqtx.html