# How do I create an index name based on a time field that is not the timestamp?

**URL:** <https://discuss.elastic.co/t/how-do-i-create-an-index-name-based-on-a-time-field-that-is-not-the-timestamp/112035>\
**Category:** Logstash\
**Created:** [December 15, 2017, 7:08pm UTC](https://discuss.elastic.co/t/how-do-i-create-an-index-name-based-on-a-time-field-that-is-not-the-timestamp/112035 "2017-12-15T19:08:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![arisbanach](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@arisbanach](https://discuss.elastic.co/u/arisbanach)\
**Post date:** [December 15, 2017, 7:08pm UTC](https://discuss.elastic.co/t/how-do-i-create-an-index-name-based-on-a-time-field-that-is-not-the-timestamp/112035/1 "2017-12-15T19:08:45Z")

</div>

I am using the `@timestamp` field for when the document was indexed, but have a separate field (`[page][post_date]`) for a date of when the event occurred. I would like to create index names based on the `[page][post_date]` field. However, that field is in the default `TIMESTAMP_ISO8601` format. I just want to have the standard index name of `something-yyyy-MM-dd`.

How can I do this?

Thank you.

---

<div class="post-metadata">

**Author:** ![Kurt\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kurt_s/32/17755_2.png) [@Kurt\_S](https://discuss.elastic.co/u/Kurt_S)\
**Post date:** [December 18, 2017, 12:13am UTC](https://discuss.elastic.co/t/how-do-i-create-an-index-name-based-on-a-time-field-that-is-not-the-timestamp/112035/2 "2017-12-18T00:13:30Z")

</div>

The way I would do it is first copy @timestamp to a new field, for instance "indexed\_date" and then overwrite @timestamp with your post\_date field.  
If that's not an option, you could use an alias for the index in logstash, like "indexname-actieve" and in elasticsearch you could then use the rollover api and curator to rollover the index daily. More information on that is in [this blogpost](https://www.elastic.co/blog/managing-time-based-indices-efficiently).

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 18, 2017, 6:25am UTC](https://discuss.elastic.co/t/how-do-i-create-an-index-name-based-on-a-time-field-that-is-not-the-timestamp/112035/3 "2017-12-18T06:25:19Z")

</div>

Assuming you don't want to use the `@timestamp` field for the post date you need to transform the `[page][post_date]` field (or a copy of it) into whatever format you prefer (using grok, mutate, or whatever filters you prefer) and reference it in the `index` option with the `%{fieldname}` notation.

---

<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:** [January 15, 2018, 6:25am UTC](https://discuss.elastic.co/t/how-do-i-create-an-index-name-based-on-a-time-field-that-is-not-the-timestamp/112035/4 "2018-01-15T06:25:25Z")

</div>

Closed on January 15, 2018, 6:25am UTC

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