如何使用logstash.yml中Filebeat中指定的索引?

时间:2018-08-18 07:50:04

标签: logstash elastic-stack filebeat

我正在使用Filebeat通过以下配置将日志文件发送到我的Logstash

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - ${PWD}/filebeat-volume/data/*.txt

output.logstash:
  enabled: true
  hosts: ["elk:5044"]
  index: "custom-index"

setup.kibana:
  host: "localhost:5601"

input {
  beats {
    port => "5044"
  }
}

output {
  elasticsearch {
    hosts => [ "localhost:9200" ]
    index => "<WHAT SHOULD GO HERE???>"
  }
}

filebeat.yml中,我指定一个索引(“自定义索引”)。如何在logstash.yml中设置相同的索引发送给Elasticsearch

1 个答案:

答案 0 :(得分:1)

我现在明白了,您应该使用下面的输出配置来设置Logstash,这样它将把filebeat中设置的索引传递给Elasticsearch。

output {
  elasticsearch {
    hosts => [ "localhost:9200" ]
    index => "%{[@metadata][beat]}"
  }
}

Point 2 in this example