如何从 logstash 控制弹性索引中的分片数量?

How to control number of shards in Elastic index from logstash?

我想控制一个新索引在我的 logstash 输出文件中应该有多少个分片。例如:

10-output.conf:

output {
    if [type] == "mytype" {
    elasticsearch {
       hosts => [ "1.1.1.1:9200"  ]
       index => "logstash-mytype-%{+YYYY.ww}"
       workers => 8
       flush_size => 1000
       ? <====== what option to control the number of index shards goes here?
    }
}

根据我在 logstash elastic options 中的理解,这是不可能的,新索引将默认为 5 个分片?

Logstash-Elasticsearch 组合的设计工作方式与您的预期不同:在 Elasticsearch 中定义了一个 index template,其中数字或分片是一项配置设置。

每当 Logstash 通过将文档发送到这个新索引来创建新索引时,Elasticsearch 使用该索引模板(通过将新索引名称与配置的模板匹配)来实际创建索引。