根据日志来源的不同生成不同的index索引

使用filebeat收集系统日志,不同应用的日志,然后把这些日志传输给Logstash,再然后交由elasticsearch处理,那么如何区分不同的日志来源呢?

  1. filebeat.yml配置文件中不启动模块,全部使用如下方式输出日志
filebeat.inputs:

- type: log
  enabled: true
  paths:
    - /var/log/logstash/logstash-plain.log
  
  fields:
    log_source: logstash
  fields_under_root: true

  multiline.pattern: ^\d{4}-\d{1,2}-\d{1,2}
  multiline.negate: true
  multiline.match: after

  scan_frequency: 5s
  close_inactive: 1h  
  ignore_older: 24h

2.logstash目录下conf.d/*.conf配置文件依据log_source的值不同,生成不同的index索引
具体参数还可以增加,过滤条件还可以设置

output {

  if [log_source] == "logstash" {
    elasticsearch {
      hosts => ["http://localhost:9200"]
      index => "logstash-%{+YYYY.MM.dd}"
      #user => "elastic"
      #password => "changeme"
    }
  }
}

猜你喜欢

转载自www.cnblogs.com/sanduzxcvbnm/p/11416164.html
今日推荐