PUT _ilm/policy/test_event_policy
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": {
"max_size":"1k",
"max_docs": "100",
"max_age":"10s"
}
}
},
"delete" : {
"min_age": "60s",
"actions": {
"delete": {}
}
}
}
}
}
위에서 정의한 ILM 정책을 index template 의 index.lifecycle.name
에 지정한다
index 자체에 설정하는 것이 아니라 템플릿에서 지정한다.
mapping, shard 등 index template 설정도 지정
index_patterns
에는 rollover 되며 template 이 적용될 index 패턴을 기입
index.lifecycle.rollover_alias
에는 rollover 되며 index 들에 alias 명칭 등록
PUT _index_template/test_event_template
{
"index_patterns": ["test_event-*"],
"template": {
"settings": {
"number_of_shards": 10,
"number_of_replicas": 1,
"index.lifecycle.name": "test_event_policy",
"index.lifecycle.rollover_alias": "test_event",
"analysis" : {
"analyzer" : {
"test_analyzer" : {
"filter" : [
"lowercase",
"stop",
"snowball"
],
"char_filter" : [
"test_char_filter"
],
"tokenizer" : "whitespace"
}
},
"char_filter" : {
"test_char_filter" : {
"type" : "mapping",
"mappings" : [
"+ => _plus_",
"- => _minus_"
]
}
}
}
},
"mappings" : {
"properties" : {
"my_keyword_field" : {
"type" : "keyword"
},
"my_text_field" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword"
}
},
"analyzer" : "test_analyzer"
},
}
}
}
}
is_write_index
를 true
로 설정하여 쓰기 가능한 index를 생성한다.index_patters
에 지정한 index명에 맞게 지정PUT test_event-000001
{
"aliases": {
"test_event": {
"is_write_index": true
}
}
}
put test1_event/_doc/
{
"my_keyword_field": "man",
"my_text_field" : "test now..."
}
GET test_event/_ilm/explain
GET test_event-000001/_ilm/explain
{
"indices" : {
"test_event-000004" : {
"index" : "test_event-000004",
"managed" : true,
"policy" : "test_event_policy",
"lifecycle_date_millis" : 1660804553340,
"age" : "19.68s",
"phase" : "hot",
"phase_time_millis" : 1660804534725,
"action" : "complete",
"action_time_millis" : 1660804557486,
"step" : "complete",
"step_time_millis" : 1660804557486,
"phase_execution" : {
"policy" : "test_event_policy",
"phase_definition" : {
"min_age" : "0ms",
"actions" : {
"rollover" : {
"max_size" : "1kb",
"max_age" : "10s",
"max_docs" : 100
}
}
},
"version" : 2,
"modified_date_in_millis" : 1660804472526
}
},
"test_event-000005" : {
"index" : "test_event-000005",
"managed" : true,
"policy" : "test_event_policy",
"lifecycle_date_millis" : 1660804553364,
"age" : "19.66s",
"phase" : "hot",
"phase_time_millis" : 1660804555155,
"action" : "rollover",
"action_time_millis" : 1660804565998,
"step" : "check-rollover-ready",
"step_time_millis" : 1660804565998,
"phase_execution" : {
"policy" : "test_event_policy",
"phase_definition" : {
"min_age" : "0ms",
"actions" : {
"rollover" : {
"max_size" : "1kb",
"max_age" : "10s",
"max_docs" : 100
}
}
},
"version" : 2,
"modified_date_in_millis" : 1660804472526
}
},
"test_event-000002" : {
"index" : "test_event-000002",
"managed" : true,
"policy" : "test_event_policy",
"lifecycle_date_millis" : 1660804513217,
"age" : "59.8s",
"phase" : "hot",
"phase_time_millis" : 1660804494575,
"action" : "complete",
"action_time_millis" : 1660804518066,
"step" : "complete",
"step_time_millis" : 1660804518066,
"phase_execution" : {
"policy" : "test_event_policy",
"phase_definition" : {
"min_age" : "0ms",
"actions" : {
"rollover" : {
"max_size" : "1kb",
"max_age" : "10s",
"max_docs" : 100
}
}
},
"version" : 2,
"modified_date_in_millis" : 1660804472526
}
},
"test_event-000003" : {
"index" : "test_event-000003",
"managed" : true,
"policy" : "test_event_policy",
"lifecycle_date_millis" : 1660804533048,
"age" : "39.97s",
"phase" : "hot",
"phase_time_millis" : 1660804515272,
"action" : "complete",
"action_time_millis" : 1660804537452,
"step" : "complete",
"step_time_millis" : 1660804537452,
"phase_execution" : {
"policy" : "test_event_policy",
"phase_definition" : {
"min_age" : "0ms",
"actions" : {
"rollover" : {
"max_size" : "1kb",
"max_age" : "10s",
"max_docs" : 100
}
}
},
"version" : 2,
"modified_date_in_millis" : 1660804472526
}
}
}
}