# Date math in index name error in 8.1.3

**URL:** <https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186>\
**Category:** Elasticsearch\
**Created:** [May 19, 2022, 12:13pm UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186 "2022-05-19T12:13:14Z")\
**Posts on this page:** 14\
**Page:** 1

<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:** [May 19, 2022, 12:13pm UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/1 "2022-05-19T12:13:14Z")

</div>

Per the [doc](https://www.elastic.co/guide/en/elasticsearch/reference/8.1/api-conventions.html#api-date-math-index-names), I'm trying to create an index with the date in it's name:

```auto
PUT /%3Call-dns-%7Bnow%2Fd%7D%-0000013E?pretty
{
  "aliases": {
    "all-dns": {
      "is_write_index": true
    }
  }
}

```

But I'm getting this error:

> {  
> "error" : "Incorrect HTTP method for uri [/%3Call-dns-%7Bnow/d%7D%25-0000013E?pretty=&pretty=true] and method [PUT], allowed: [POST]",  
> "status" : 405  
> }  
> Changing the method to POST is no better:

```auto
{
  "error" : "no handler found for uri [/%3Call-dns-%7Bnow/d%7D%25-0000013E?pretty=&pretty=true] and method [POST]"
}

```

This used to work, because I just changed the name in prior commands devtools.

---

<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:** [May 19, 2022, 2:43pm UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/2 "2022-05-19T14:43:18Z")

</div>

Think you are missing the last `%` before the `3E`

`PUT /%3Call-dns-%7Bnow%2Fd%7D-000001%3E?pretty`

---

<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:** [May 19, 2022, 6:35pm UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/3 "2022-05-19T18:35:57Z")

</div>

Still not working, I don't know if I lost the % posting or what, but re-testing:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/9/e949f01dbfd81c2865004c6b2c8b6b2c6496d7b2.png)

---

<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:** [May 19, 2022, 6:37pm UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/4 "2022-05-19T18:37:23Z")

</div>

@rugenl Screen shot BAH! please post the actual text so I can try!

Mine on 8.2.0 (should be same in 8.1.3)

```auto
PUT /%3Call-dns-%7Bnow%2Fd%7D-000001%3E?pretty
{
  "aliases": {
    "all-dns": {
      "is_write_index": true
    }
  }
}

```

response

```auto
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "all-dns-2022.05.19-000001"
}

```

Something weird in your url...

 ![Screen Shot 2022-05-19 at 11.47.31 AM](https://us1.discourse-cdn.com/elastic/original/3X/d/6/d6ab89dcf40cd93a28a200b41bdf20585365ee41.png)

When I purposely use wrong method my url prints this... note no `/` where yours is

`"error" : "Incorrect HTTP method for uri [/%3Call-dns-%7Bnow%2Fd%7D-000001%3E?pretty=&pretty=true]`

---

<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:** [May 25, 2022, 6:06pm UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/5 "2022-05-25T18:06:50Z")

</div>

Stay tuned, same syntax that fails in 8.1.3 works in 7.17.1.

I knew we used this many times before and was pretty sure I started with an example that had worked in the past.

---

<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:** [May 25, 2022, 8:16pm UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/6 "2022-05-25T20:16:34Z")

</div>

@rugenl

Interesting I reproduced the error in 8.1.3

```auto
PUT /%3Call-dns-%7Bnow%2Fd%7D-000001%3E?pretty
{
  "aliases": {
    "all-dns": {
      "is_write_index": true
    }
  }
}

```

results

```auto
{
  "error" : "Incorrect HTTP method for uri [/%3Call-dns-%7Bnow/d%7D-000001%3E?pretty=&pretty=true] and method [PUT], allowed: [POST]",
  "status" : 405
}

```

Note it has that extra `/` in it

in 8.2.0 It works fine.. so looks like there is a bug in 8.1.3 that is fixed in 8.2.0

You can certainly create manually with the following syntax or upgrade to 8.2.0

```auto
PUT all-dns-2022.05.19-000001?pretty
{
  "aliases": {
    "all-dns": {
      "is_write_index": true
    }
  }
}

```

---

<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:** [May 26, 2022, 1:36am UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/7 "2022-05-26T01:36:22Z")

</div>

Known issue: [[Console] Cannot issue request with date-math format · Issue #128701 · elastic/kibana · GitHub](https://github.com/elastic/kibana/issues/128701)

---

<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:** [May 26, 2022, 1:37am UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/8 "2022-05-26T01:37:27Z")

</div>

That format is a ILM red herring, all indices will have 2022.05.19, not the current date at rollover.

---

<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:** [May 26, 2022, 3:57am UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/9 "2022-05-26T03:57:41Z")

</div>

Good Find on the issue.

> [@rugenl](#):
>
> That format is a ILM red herring, all indices will have 2022.05.19, not the current date at rollover.

Unclear what you mean.

---

<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:** [May 26, 2022, 4:03am UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/10 "2022-05-26T04:03:34Z")

</div>

Using the date math {now/d} will put the current date at rollover in the index name at each rollover event. If you use a literal date for the first index, that date will be used in all future indices.

---

<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:** [May 26, 2022, 4:39am UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/11 "2022-05-26T04:39:05Z")

</div>

> [@rugenl](#):
>
> Using the date math {now/d} will put the current date at rollover in the index name at each rollover event. If you use a literal date for the first index, that date will be used in all future indices.

Hmmm I will need to validate for myself as I was not aware of that / not my understanding ... unfortunately to validate I need to wait for a UTC date rollover to trigger the date portion in 20 hours (pretty sure I have manually bootstrapped many indices with the literal... but perhaps I am wrong or something has changed) either way now I have to know 🙂 Thanks for pointing out.

---

<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:** [May 26, 2022, 2:47pm UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/12 "2022-05-26T14:47:39Z")

</div>

It burned me early in ILM, it's been awhile, it's possible it's fixed, but I think it needs the {date/d} in the "provided\_name" field in the index to know a date isn't a constant.

---

<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:** [May 27, 2022, 2:19am UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/13 "2022-05-27T02:19:31Z")

</div>

@rugenl Yes You Are Correct you must use the `{now/d}` syntax...

So for anyone reading this your date driven rollover must be defined with the correct syntax

In Kibana -\> Dev Tools you can use the non encoded syntax (in some versions)

```auto
PUT /<my-index-{now/d}-000001>?pretty
{
  "aliases": {
    "my-index-write-alias": {
      "is_write_index": true
    }
  }
}

```

If you are posting through a REST endpoint you will need to encode

```auto
PUT /%3Cmy-index-%7Bnow%2Fd%7D-000001%3E?pretty
{
  "aliases": {
    "my-index-write-alias": {
      "is_write_index": true
    }
  }
}

```

BTW @rugenl I realized I was thinking of the non date form with the of the beats aliases

```auto
PUT /filebeat-7.17.3-000001/?pretty
{
  "aliases": {
    "filebeat-7.17.3: {
      "is_write_index": true
    }
  }
}

```

---

<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:** [June 24, 2022, 2:20am UTC](https://discuss.elastic.co/t/date-math-in-index-name-error-in-8-1-3/305186/14 "2022-06-24T02:20:05Z")

</div>

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