简体   繁体   中英

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

I would like to control how many shards a new index should have in my logstash output file. Ex:

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?
    }
}

From what I understand in logstash elastic options this is not possible and new index will default to 5 shards?

The Logstash-Elasticsearch mix it's designed to work differently than what your expectation is: in Elasticsearch one defines an index template in which the number or shards is a configuration setting.

And whenever Logstash creates a new index by sending documents to this new index, Elasticsearch uses that index template (by matching the new index name with the configured template) to actually create the index.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM