# Time series data, use template to auto-create monthly

**URL:** https://discuss.elastic.co/t/time-series-data-use-template-to-auto-create-monthly/48825
**Category:** Elasticsearch
**Created:** [April 29, 2016, 4:42pm UTC](https://discuss.elastic.co/t/time-series-data-use-template-to-auto-create-monthly/48825 "2016-04-29T16:42:21Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ronchalant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ronchalant/32/3611_2.png) [@ronchalant](https://discuss.elastic.co/u/ronchalant)
#### Post date: [April 29, 2016, 4:42pm UTC](https://discuss.elastic.co/t/time-series-data-use-template-to-auto-create-monthly/48825/1 "2016-04-29T16:42:21Z")

</div>

I have time series data but instead of automatic creation of an index based on the @timestamp value, I want to be able to create it from a value _within_ the document itself, and I'd also like to have the index created monthly rather than daily if possible.

So for example I might have a "my\_date" field in the mapping, each time the month rolls over it would parse out "yyyy-mm" or whatever and create a new index "my\_index-2016-05" from the specified template (which would roll into an alias "my\_index" perhaps).

Is that possible, or am I going to need to provide custom index & alias management for that?

Thanks!

---

<div class="post-metadata">

### Author: ![ronchalant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ronchalant/32/3611_2.png) [@ronchalant](https://discuss.elastic.co/u/ronchalant)
#### Post date: [April 29, 2016, 10:15pm UTC](https://discuss.elastic.co/t/time-series-data-use-template-to-auto-create-monthly/48825/2 "2016-04-29T22:15:27Z")

</div>

Nevermind, I figured it out.. I was simply misunderstanding how templates worked.

---

<div class="post-metadata">

### Author: ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)
#### Post date: [April 29, 2016, 10:18pm UTC](https://discuss.elastic.co/t/time-series-data-use-template-to-auto-create-monthly/48825/3 "2016-04-29T22:18:33Z")

</div>

Since you are asking about @timestamp, I presume you are using logstash? You should ask in the logstash category. From the elasticsearch side, the index name is part of the indexing request. As far as aliases, you will need to manage these yourself, or use something like [curator](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html).

---

<div class="post-metadata">

### Author: ![Kulasangar\_Gowrisang](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kulasangar\_Gowrisang](https://discuss.elastic.co/u/Kulasangar_Gowrisang)
#### Post date: [February 8, 2017, 11:18am UTC](https://discuss.elastic.co/t/time-series-data-use-template-to-auto-create-monthly/48825/4 "2017-02-08T11:18:38Z")

</div>

@ronchalant

Hi Ron, I'm trying to create indices automatically on a monthly basis.

Your input on how you managed to do yours, would help me! Sorry for pulling out an old thread

Thanks.

---

<div class="post-metadata">

### Author: ![ronchalant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ronchalant/32/3611_2.png) [@ronchalant](https://discuss.elastic.co/u/ronchalant)
#### Post date: [February 19, 2017, 7:31pm UTC](https://discuss.elastic.co/t/time-series-data-use-template-to-auto-create-monthly/48825/5 "2017-02-19T19:31:48Z")

</div>

Sorry for the delay, I just saw this.

Basically my initial assumption about how the templates work was incorrect. I was using the marvel template and indices as a reference, and made the false assumption that the format was somehow part of elastic.

It's not. Basically the template property with a trailing `*` is what is used by Elastic to determine upon implicit index creation if there is a template to use.

so if you create your template with a property like `"template": "myindex_*"` and then adjust your indexing process so that when it goes to index it generates the index name dynamically, you would have the index be "myindex\_201702" or something like that if you want them to be monthly.

I hope (?) that clarifies

---

<div class="post-metadata">

### Author: ![Kulasangar\_Gowrisang](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kulasangar\_Gowrisang](https://discuss.elastic.co/u/Kulasangar_Gowrisang)
#### Post date: [March 1, 2017, 8:45am UTC](https://discuss.elastic.co/t/time-series-data-use-template-to-auto-create-monthly/48825/6 "2017-03-01T08:45:22Z")

</div>

Thank you so much Ron.

I actually rolled out the time-based indices by doing this in my `elasticsearch` output:

`index => "myindex-%{year}-%{month}"`

_year_ and _month_ are fields from my database table which actually made my life more easier.

Thank you again 🙂

---

<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: [July 5, 2017, 10:02pm UTC](https://discuss.elastic.co/t/time-series-data-use-template-to-auto-create-monthly/48825/7 "2017-07-05T22:02:47Z")

</div>


