多个Filebeat输入到Logstash设置不一样的索引

需求

对每一台机器上都装一个filebeat,而后都指向同一个logstash,这时不一样的filebeat传输的数据过来,须要输出到不一样的索引,nginx

 

 

办法

在filebeat的配置文件里添加 fields.service: nginx(可自定义)
 
filebeat.prospectors:
- type: log  
  enabled: true

  paths:
    - /var/log/nginx-json/access.log

  input_type: log
  fields.document_type: nginx
  fields.service: nginx
  tags: ["nginx"]

filebeat.config.modules:
 
  path: ${path.config}/modules.d/*.yml

  reload.enabled: false

output.logstash:
    hosts: ["10.0.0.5:5044"]

 

在Logstash的配置文件里: 添加 if [fields][service] == "nginx"{...}
 
output { if [fields][service] == "nginx"{ elasticsearch { hosts => ["http://localhost:9200"] index => "h5-nginx-%{+YYYY.MM.dd}" } } }
相关文章
相关标签/搜索