# Is it possible to create two index for the same day using logstash templete

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-create-two-index-for-the-same-day-using-logstash-templete/197022>\
**Category:** Logstash\
**Created:** [August 28, 2019, 2:56am UTC](https://discuss.elastic.co/t/is-it-possible-to-create-two-index-for-the-same-day-using-logstash-templete/197022 "2019-08-28T02:56:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![RITZ\_VERMA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ritz_verma/32/46899_2.png) [@RITZ\_VERMA](https://discuss.elastic.co/u/RITZ_VERMA)\
**Post date:** [August 28, 2019, 2:56am UTC](https://discuss.elastic.co/t/is-it-possible-to-create-two-index-for-the-same-day-using-logstash-templete/197022/1 "2019-08-28T02:56:33Z")

</div>

I am using logstash to send data elasticsearch on daily basis but the size of the indexes created is too large .that is why i want ot create two index for the same day.is it possible using logstash

---

<div class="post-metadata">

**Author:** ![rugenl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rugenl/32/12887_2.png) [@rugenl](https://discuss.elastic.co/u/rugenl)\
**Post date:** [August 28, 2019, 12:04pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-two-index-for-the-same-day-using-logstash-templete/197022/2 "2019-08-28T12:04:59Z")

</div>

This is typically handled by setting shards to a value that would get each shard to around 50G.

ILM is your future, it can rollover an index at size limit.

---

<div class="post-metadata">

**Author:** ![RITZ\_VERMA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ritz_verma/32/46899_2.png) [@RITZ\_VERMA](https://discuss.elastic.co/u/RITZ_VERMA)\
**Post date:** [August 28, 2019, 2:00pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-two-index-for-the-same-day-using-logstash-templete/197022/3 "2019-08-28T14:00:11Z")

</div>

Can we do it like this for hourly logs  
output{  
elasticsearch{  
index =\> index\_name%{+YY.MM.dd.HH}  
}  
}

and if this is possible is there a way to do it for every 12 hours

---

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [August 28, 2019, 2:44pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-two-index-for-the-same-day-using-logstash-templete/197022/4 "2019-08-28T14:44:27Z")

</div>

Maybe it will be not ideal but you could do the following:  
parse the date from @timestamp, and check if the hour in the timestamp is having a certain value.

> grok {  
> #process the @timestamp  
> }
> 
> if [hour] \>= 12 {  
> mutate {  
> add\_field =\> {"index\_rotator"=\> "1"}  
> }  
> }  
> else {  
> mutate {  
> add\_field =\> {"index\_rotator"=\> "2"}  
> }  
> }
> 
> so you can have a predictable:
> 
> output{  
> elasticsearch{  
> index =\> index\_name%{+YY.MM.dd}-%{index\_rotator}  
> }  
> }

Or just use the \_ilm.  
It is much better and this is for what it was designed to.

BTW. What is your usecase? To store some log data? To query that data you are loading?

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [August 28, 2019, 2:50pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-two-index-for-the-same-day-using-logstash-templete/197022/5 "2019-08-28T14:50:55Z")

</div>

> [@RITZ\_VERMA](#):
>
> Can we do it like this for hourly logs  
> output{  
> elasticsearch{  
> index =\> index\_name%{+YY.MM.dd.HH}  
> }  
> }

yes it should work. I have tested with ww (weekly index) and it worked

---

<div class="post-metadata">

**Author:** ![RITZ\_VERMA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ritz_verma/32/46899_2.png) [@RITZ\_VERMA](https://discuss.elastic.co/u/RITZ_VERMA)\
**Post date:** [August 28, 2019, 5:29pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-two-index-for-the-same-day-using-logstash-templete/197022/6 "2019-08-28T17:29:46Z")

</div>

Thanks @pastechecker it may be not ideal but for now it will serve the purpose.Meanwhile i will try to find if there is a better way

---

<div class="post-metadata">

**Author:** ![RITZ\_VERMA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ritz_verma/32/46899_2.png) [@RITZ\_VERMA](https://discuss.elastic.co/u/RITZ_VERMA)\
**Post date:** [August 28, 2019, 5:31pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-two-index-for-the-same-day-using-logstash-templete/197022/7 "2019-08-28T17:31:12Z")

</div>

Hey @elasticforme Can you show me what index pattern you used for weekly index

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [August 28, 2019, 6:14pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-two-index-for-the-same-day-using-logstash-templete/197022/8 "2019-08-28T18:14:49Z")

</div>

in output section  
output {  
elasticsearch {  
index =\> "resource-%{+YYYY.ww}"  
}  
}

or you can use xxxx.ww

Follow this discussion

[https://discuss.elastic.co/t/solved-weekly-indexes-instead-of-daily/56871](https://discuss.elastic.co/t/solved-weekly-indexes-instead-of-daily/56871)

---

<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:** [September 25, 2019, 6:14pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-two-index-for-the-same-day-using-logstash-templete/197022/9 "2019-09-25T18:14:59Z")

</div>

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