试试搜索一下吧

Filebeat6.0.x 版本多个index配置

Beats | 作者 songgl | 发布于2017年12月11日 | 阅读数:12224

ES6 不再支持自己在同一个index下定义多个type. 因此 以前 filebeat中的 document_type 配置不再生效。
同时,由于 filebeat的 output.elasticsearch中的index配置并不能具体到 prospector 之中,所以一份配置文件只能共用一个index.
 
如果我有两个日志文件 info.log err.log 
 
我需要写入到同一个es集群中的 log_info 、log_err 两个 index中,该如何配置?
 
文档给出了一个基于日志内容字段匹配的方案:

l.png

 
但是有一个问题是,如果这两个日志文件无法通过特定的字段来区分,该如何实现将两个文件的内容分别插入到不同的index中?
 
有一个临时方案是,分别启动两个 fiilebeat 实例,通过 --path.config 指定不同的配置文件,两个配置文件中配置不同的 index。
 
在 filebeat 支持 每个prospector 可以配置独立的 index之前,有没有其他比较好的方案?
 
已邀请:

rockybean - Elastic Certified Engineer, ElasticStack Fans,公众号:ElasticTalk

赞同来自: bibby songgl

可以写到多个 index,已实验,参看如下配置,就是你问题里的方法,加一个字段
 


filebeat:
  setup:
  kibana: null
  template:
    name: mylog
    overwrite: true
    pattern: mylog-*
  prospectors:
  - enabled: true
    fields:
      source: system
    paths:
    - /var/log/system.log
    type: log
  - enabled: true
    fields:
      source: nginx
    paths:
    - /var/log/nginx.log
    type: log
output:
  elasticsearch:
    hosts:
    - localhost:9200
    index: mylog-%{+yyyy.MM.dd}
    indices:
    - index: mylog-nginx-%{+yyyy.MM.dd}
      when:
        contains:
          source: nginx
    - index: mylog-system-%{+yyyy.MM.dd}
      when:
        contains:
          source: system

bibby

赞同来自: rockybean songgl

rockybean正解,另外刚刚试验过,以nginx日志为例,output elasticsearch也可以用equals来判断:
output.elasticsearch:
hosts: ["ip:9200"]
indices:
- index: "ip-nginx-access-%{+yyyy.MM.dd}"
when.equals:
fileset.module: "nginx"
fileset.name: "access"
- index: "ip-nginx-error-%{+yyyy.MM.dd}"
when.equals:
fileset.module: "nginx"
fileset.name: "error"

wntp - 80后IT♂

赞同来自:

你之前的type是如何区分的呢?

songgl

赞同来自:

考虑用 logstash 替换掉 filebeat 

songgl

赞同来自:

查了下 beat的论坛,说 beat不支持将内容写入到多个index之中。需要需要将内容写到多个index, 可以在 filebeat 和 es之间加一层 logstash .

jianfzhu

赞同来自:

上面的例子中filebeat 接logstash 怎么配置?
 
logstash output 怎么写?
 

要回复问题请先登录注册