N
N
Nikita Reshetnyak2021-03-19 13:54:54
elasticsearch
Nikita Reshetnyak, 2021-03-19 13:54:54

How to set up ILM correctly?

Good day! I'm trying to get ILM to work. I will say right away, I am doing it for the first time, I googled a lot, understanding did not come.
There is an index app-dev-logs-7.6.2

Index template

PUT _template/app
{
  "order": 100,
  "index_patterns": [
    "app-dev-logs-7.6.2-*"
  ],
  "settings": {
    "index": {
      "lifecycle": {
        "name": "app",
        "rollover_alias": "app-dev-logs-7.6.2"
      }
    }
  },
  "mappings": {
    "_doc": {
      "_meta": {},
      "_source": {},
      "properties": {}
    }
  }
}


ILM Policy

PUT _ilm/policy/app
{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0ms",
        "actions": {
          "rollover": {
            "max_age": "1m",
            "max_size": "50gb"
          },
          "set_priority": {
            "priority": 100
          }
        }
      },
      "delete": {
        "min_age": "1nanos",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}


As a result, I get the error

illegal_argument_exception: index name [app-dev-logs-7.6.2-03.2021] does not match pattern '^.*-\d+$'

After some edits, the error disappears. But no action takes place. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2021-03-19
@vitaly_il1

1) If the goal is not to learn how to do it through the API, but simply to create a policy, you can do it in Kibana
2) when you create a policy, what does Elastic respond to?

"delete": {
"min_age": "1nanos",

There is a logical error here - we do not want to delete indexes after 1nanos.
I suggest something like
"min_age": "1d"
Or one hour.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question