# Configuring index template to set number of shards

**URL:** https://discuss.elastic.co/t/configuring-index-template-to-set-number-of-shards/116774
**Category:** Elasticsearch
**Created:** [January 23, 2018, 11:57pm UTC](https://discuss.elastic.co/t/configuring-index-template-to-set-number-of-shards/116774 "2018-01-23T23:57:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zachy](https://avatars.discourse-cdn.com/v4/letter/z/9d8465/32.png) [@zachy](https://discuss.elastic.co/u/zachy)
#### Post date: [January 23, 2018, 11:57pm UTC](https://discuss.elastic.co/t/configuring-index-template-to-set-number-of-shards/116774/1 "2018-01-23T23:57:01Z")

</div>

Hi

I was wondering how one would be able to change the default index template. For instance, I would like to configure the number of primary and replica shards for each index.

Is there a way to do it without the API? This is because Logstash is listening in on a live Kafka outlet, so data is almost immediately ingested when my ELK stack boots up.

Any help or direction appreciated.

Thanks!

---

<div class="post-metadata">

### Author: ![Shaoranlaos](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Shaoranlaos](https://discuss.elastic.co/u/Shaoranlaos)
#### Post date: [January 24, 2018, 6:38am UTC](https://discuss.elastic.co/t/configuring-index-template-to-set-number-of-shards/116774/2 "2018-01-24T06:38:40Z")

</div>

you can define the index template on the es output in logstash  
[https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-template](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-template)  
and following options

so that logstash will automatically install the index template on startup

es index template definition  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html#indices-templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html#indices-templates)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 21, 2018, 6:39am UTC](https://discuss.elastic.co/t/configuring-index-template-to-set-number-of-shards/116774/3 "2018-02-21T06:39:02Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
