# Date format increasing doesn't work

**URL:** <https://discuss.elastic.co/t/date-format-increasing-doesnt-work/343818>\
**Category:** Beats\
**Tags:** ilm-index-lifecycle-management, metricbeat\
**Created:** [September 26, 2023, 1:19am UTC](https://discuss.elastic.co/t/date-format-increasing-doesnt-work/343818 "2023-09-26T01:19:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![20wjsdudtj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/20wjsdudtj/32/124686_2.png) [@20wjsdudtj](https://discuss.elastic.co/u/20wjsdudtj)\
**Post date:** [September 26, 2023, 1:19am UTC](https://discuss.elastic.co/t/date-format-increasing-doesnt-work/343818/1 "2023-09-26T01:19:41Z")

</div>

After assigning my ILM policy as follows:

```auto
PUT /_ilm/policy/my_policy
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_size": "50gb",
            "max_age": "30d"
          }
        }
      }
    }
  }
}

```

And configuring my Metricbeat file with date-based indexing as follows:

```auto
output.elasticsearch:
  hosts: ***
  protocol: "https"
  username: ***
  password: ****
  index: "metric-example-%{+yyyy.MM.dd}"

```

However, I noticed that it only works for one day, such as "2023-09-20," and does not proceed to the next day. Why is this error occurring?

When I try to index without specifying the date, like "PUT metricbeat-\*\*\*," I encounter the following error:

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "invalid_index_name_exception",
        "reason": "Invalid index name [pororometrics], already exists as alias",
        "index_uuid": "_na_",
        "index": "pororometrics"
      }
    ],
    "type": "invalid_index_name_exception",
    "reason": "Invalid index name [pororometrics], already exists as alias",
    "index_uuid": "_na_",
    "index": "pororometrics"
  },
  "status": 400
}

```

and for my first index, it turns like "\<metrics-{now/d}-000001\>" for provided\_name. I think it should be metrics-2023-09-20-00001.

```auto
{
  "settings": {
    "index": {
      "mapping": {
        "total_fields": {
          "limit": "10000"
        }
      },
      "refresh_interval": "30s",
      "provided_name": "<metrics-{now/d}-000001>",
      "query": {
        "default_field": [

```

Can you explain why these issues are happening?

---

<div class="post-metadata">

**Author:** ![20wjsdudtj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/20wjsdudtj/32/124686_2.png) [@20wjsdudtj](https://discuss.elastic.co/u/20wjsdudtj)\
**Post date:** [October 10, 2023, 12:48am UTC](https://discuss.elastic.co/t/date-format-increasing-doesnt-work/343818/2 "2023-10-10T00:48:03Z")

</div>

This is my question-and-answer.

If you have/wanted to set an alias alias (ex. setup.ilm.rollover\_alias: "hellometrics”) to the index, set is\_write\_index: true to the alias as stated in the official document here([Rollover API | Elasticsearch Guide [master] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html#_using_date_math_with_the_rollover_api)) so that the date and rollover are written separately in the alias. Be careful to specify it!

```auto
# PUT <my-index-{now/d}-000001>
PUT %3Cmy-index-%7Bnow%2Fd%7D-000001%3E
{
  "aliases": {
    "my-alias": {
      "is_write_index": true
    }
  }
}

```

You'd better write your xml file like this.

```auto
metricbeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
  reload.period: 10s

setup.template.settings:
  index.number_of_shards: 1
  index.codec: best_compression
setup.template.name: "metric-secret"
setup.template.pattern: "metric-secret-*"
setup.template.overwrite: false
setup.ilm.enabled: false
setup.ilm.policy_name: "my_policy"

```

---

<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:** [November 7, 2023, 2:48am UTC](https://discuss.elastic.co/t/date-format-increasing-doesnt-work/343818/3 "2023-11-07T02:48:56Z")

</div>

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