# Shard creation when using index pattern

**URL:** <https://discuss.elastic.co/t/shard-creation-when-using-index-pattern/288099>\
**Category:** Elasticsearch\
**Created:** [October 31, 2021, 5:58pm UTC](https://discuss.elastic.co/t/shard-creation-when-using-index-pattern/288099 "2021-10-31T17:58:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shi](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@shi](https://discuss.elastic.co/u/shi)\
**Post date:** [October 31, 2021, 5:58pm UTC](https://discuss.elastic.co/t/shard-creation-when-using-index-pattern/288099/1 "2021-10-31T17:58:12Z")

</div>

How are shards created/allocated when we are using an index pattern such that each day's log is written to a separate index (eg my\_index\_emailf\_log-\* , my\_index\_emailf\_log-dd-mm-yyyy .)

Suppose we have specified 1 primary shard and 1 replica shard for that index pattern,  
will a separate primary shard and separate replica shard gets created daily for each index that gets created daily with the name for eg my\_index\_emailf\_log-31-10-2021?

regards  
shini

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [October 31, 2021, 9:34pm UTC](https://discuss.elastic.co/t/shard-creation-when-using-index-pattern/288099/2 "2021-10-31T21:34:19Z")

</div>

Whatever the shard and replica setting are in the index template each new index that matches the pattern in the template will be created with the defined setting from the template and thus will have the defined number of Primary and Replica shards.

So yes each daily index will have the defined Primary and Replica shads, in your example 1 Primary and 1 Replica

---

<div class="post-metadata">

**Author:** ![shi](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@shi](https://discuss.elastic.co/u/shi)\
**Post date:** [November 1, 2021, 9:54am UTC](https://discuss.elastic.co/t/shard-creation-when-using-index-pattern/288099/3 "2021-11-01T09:54:26Z")

</div>

in that case there will be lots of shards created as days pass by. Is it an issue ?. Is it the correct way to do? or should i create a monthly index?  
thanks and regards  
shini

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [November 1, 2021, 3:11pm UTC](https://discuss.elastic.co/t/shard-creation-when-using-index-pattern/288099/4 "2021-11-01T15:11:55Z")

</div>

It could be an issue but that depends on the number of indices and the size of your nodes etc , that is why ILM policies can be defined as sized based instead of time based, but monthly can work as well.

For more info on sizing shards perhaps take a look [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/size-your-shards.html)

---

<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:** [November 29, 2021, 3:12pm UTC](https://discuss.elastic.co/t/shard-creation-when-using-index-pattern/288099/5 "2021-11-29T15:12:20Z")

</div>

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