Dimon Buzz
Dimon Buzz

Reputation: 1298

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?

Upvotes: 0

Views: 1968

Answers (1)

Andrei Stefan
Andrei Stefan

Reputation: 52368

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.

Upvotes: 2

Related Questions