# IndexName with current date

**URL:** <https://discuss.elastic.co/t/indexname-with-current-date/51413>\
**Category:** Logstash\
**Created:** [May 31, 2016, 10:19am UTC](https://discuss.elastic.co/t/indexname-with-current-date/51413 "2016-05-31T10:19:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prateek\_Kshtriya](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@Prateek\_Kshtriya](https://discuss.elastic.co/u/Prateek_Kshtriya)\
**Post date:** [May 31, 2016, 10:19am UTC](https://discuss.elastic.co/t/indexname-with-current-date/51413/1 "2016-05-31T10:19:42Z")

</div>

Hi All,

Please suggest how to create index name with current date.  
PFB snippet from my logstash config file-

output {  
elasticsearch {  
action =\> "index"  
index =\> "[datewise-]YYYY.MM.DD"  
}

I am getting error for name structure with above logstash config.

Regards,  
Prateek

---

<div class="post-metadata">

**Author:** ![purbon](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@purbon](https://discuss.elastic.co/u/purbon)\
**Post date:** [May 31, 2016, 10:31am UTC](https://discuss.elastic.co/t/indexname-with-current-date/51413/2 "2016-05-31T10:31:44Z")

</div>

you can see an example how to use this from the same logstash output, see [https://github.com/logstash-plugins/logstash-output-elasticsearch/blob/master/lib/logstash/outputs/elasticsearch/common\_configs.rb#L11](https://github.com/logstash-plugins/logstash-output-elasticsearch/blob/master/lib/logstash/outputs/elasticsearch/common_configs.rb#L11)

```auto
logstash-%{+YYYY.MM.dd}

```

more details as could be seen in the documentation

``` # The index to write events to. This can be dynamic using the `%{foo}` syntax.  
# The default value will partition your indices by day so you can more easily  
# delete old data or only search specific date ranges.  
# Indexes may not contain uppercase characters.  
# For weekly indexes ISO 8601 format is recommended, eg. logstash-%{+xxxx.ww}.  
# LS uses Joda to format the index pattern from event timestamp.  
# Joda formats are defined [http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html[here]](http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html%5Bhere%5D).

```auto

```

---

<div class="post-metadata">

**Author:** ![Prateek\_Kshtriya](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@Prateek\_Kshtriya](https://discuss.elastic.co/u/Prateek_Kshtriya)\
**Post date:** [May 31, 2016, 11:41am UTC](https://discuss.elastic.co/t/indexname-with-current-date/51413/3 "2016-05-31T11:41:02Z")

</div>

Thank you. It worked great for me.

Regards,  
Prateek

---

<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 6, 2017, 4:55am UTC](https://discuss.elastic.co/t/indexname-with-current-date/51413/4 "2017-07-06T04:55:16Z")

</div>


