解释生命周期 API
编辑解释生命周期 API编辑
检索一个或多个索引的当前生命周期状态。对于数据流,API 会检索流的后台索引的当前生命周期状态。
请求编辑
GET <target>/_ilm/explain
先决条件编辑
- 如果启用了 Elasticsearch 安全功能,则您必须在要管理的索引上具有
view_index_metadata
或manage_ilm
特权或两者兼有,才能使用此 API。有关更多信息,请参阅安全特权。
描述编辑
检索有关索引当前生命周期状态的信息,例如当前正在执行的阶段、操作和步骤。显示索引进入每个阶段的时间、正在运行的阶段的定义以及有关任何故障的信息。
路径参数编辑
-
<target>
- (必填,字符串)要定位的数据流、索引和别名的逗号分隔列表。支持通配符 (
*
)。要定位所有数据流和索引,请使用*
或_all
。
查询参数编辑
示例编辑
以下示例检索 my-index-000001
的生命周期状态
GET my-index-000001/_ilm/explain?human
当 ILM 首次接管索引的管理时,explain
显示该索引已受管且处于 new
阶段
{ "indices": { "my-index-000001": { "index": "my-index-000001", "index_creation_date_millis": 1538475653281, "index_creation_date": "2018-10-15T13:45:21.981Z", "time_since_index_creation": "15s", "managed": true, "policy": "my_policy", "lifecycle_date_millis": 1538475653281, "lifecycle_date": "2018-10-15T13:45:21.981Z", "age": "15s", "phase": "new", "phase_time_millis": 1538475653317, "phase_time": "2018-10-15T13:45:22.577Z", "action": "complete" "action_time_millis": 1538475653317, "action_time": "2018-10-15T13:45:22.577Z", "step": "complete", "step_time_millis": 1538475653317, "step_time": "2018-10-15T13:45:22.577Z" } } }
创建索引时,此时间戳用于确定何时进行滚动 |
|
自索引创建以来的时间(用于计算何时通过 |
|
显示索引是否由 ILM 管理。如果索引不是由 ILM 管理的,则不会显示其他字段 |
|
ILM 用于此索引的策略的名称 |
|
用于 |
|
索引的年龄(用于计算何时进入下一阶段) |
|
索引进入当前阶段的时间 |
|
索引进入当前操作的时间 |
|
索引进入当前步骤的时间 |
策略在索引上运行后,响应将包含一个 phase_execution
对象,该对象显示当前阶段的定义。在当前阶段完成之前,对基础策略的更改不会影响此索引。
{ "indices": { "test-000069": { "index": "test-000069", "index_creation_date_millis": 1538475653281, "time_since_index_creation": "25.14s", "managed": true, "policy": "my_lifecycle3", "lifecycle_date_millis": 1538475653281, "lifecycle_date": "2018-10-15T13:45:21.981Z", "age": "25.14s", "phase": "hot", "phase_time_millis": 1538475653317, "phase_time": "2018-10-15T13:45:22.577Z", "action": "rollover", "action_time_millis": 1538475653317, "action_time": "2018-10-15T13:45:22.577Z", "step": "attempt-rollover", "step_time_millis": 1538475653317, "step_time": "2018-10-15T13:45:22.577Z", "phase_execution": { "policy": "my_lifecycle3", "phase_definition": { "min_age": "0ms", "actions": { "rollover": { "max_age": "30s", "max_primary_shard_docs": 200000000, "min_docs": 1 } } }, "version": 3, "modified_date": "2018-10-15T13:21:41.576Z", "modified_date_in_millis": 1539609701576 } } } }
索引进入此阶段时从指定策略加载的 JSON 阶段定义 |
|
滚动操作包括默认的 |
|
加载的策略的版本 |
|
加载的策略上次修改的日期 |
|
加载的策略上次修改的纪元时间 |
如果 ILM 正在等待某个步骤完成,则响应将包含正在索引上执行的步骤的状态信息。
{ "indices": { "test-000020": { "index": "test-000020", "index_creation_date_millis": 1538475653281, "time_since_index_creation": "4.12m", "managed": true, "policy": "my_lifecycle3", "lifecycle_date_millis": 1538475653281, "lifecycle_date": "2018-10-15T13:45:21.981Z", "age": "4.12m", "phase": "warm", "phase_time_millis": 1538475653317, "phase_time": "2018-10-15T13:45:22.577Z", "action": "allocate", "action_time_millis": 1538475653317, "action_time": "2018-10-15T13:45:22.577Z", "step": "check-allocation", "step_time_millis": 1538475653317, "step_time": "2018-10-15T13:45:22.577Z", "step_info": { "message": "Waiting for all shard copies to be active", "shards_left_to_allocate": -1, "all_shards_active": false, "number_of_replicas": 2 }, "phase_execution": { "policy": "my_lifecycle3", "phase_definition": { "min_age": "0ms", "actions": { "allocate": { "number_of_replicas": 2, "include": { "box_type": "warm" }, "exclude": {}, "require": {} }, "forcemerge": { "max_num_segments": 1 } } }, "version": 2, "modified_date": "2018-10-15T13:20:02.489Z", "modified_date_in_millis": 1539609602489 } } } }
如果索引处于 ERROR 步骤,则表示在执行策略中的某个步骤时出错,您需要采取措施才能使索引继续进行到下一步。在某些情况下,可以安全地自动重试某些步骤。为了帮助您诊断问题,explain 响应会显示失败的步骤、提供有关错误信息的步骤信息,以及在适用情况下有关为失败步骤执行的重试尝试的信息。
{ "indices": { "test-000056": { "index": "test-000056", "index_creation_date_millis": 1538475653281, "time_since_index_creation": "50.1d", "managed": true, "policy": "my_lifecycle3", "lifecycle_date_millis": 1538475653281, "lifecycle_date": "2018-10-15T13:45:21.981Z", "age": "50.1d", "phase": "hot", "phase_time_millis": 1538475653317, "phase_time": "2018-10-15T13:45:22.577Z", "action": "rollover", "action_time_millis": 1538475653317, "action_time": "2018-10-15T13:45:22.577Z", "step": "ERROR", "step_time_millis": 1538475653317, "step_time": "2018-10-15T13:45:22.577Z", "failed_step": "check-rollover-ready", "is_auto_retryable_error": true, "failed_step_retry_count": 1, "step_info": { "type": "cluster_block_exception", "reason": "index [test-000057/H7lF9n36Rzqa-KfKcnGQMg] blocked by: [FORBIDDEN/5/index read-only (api)", "index_uuid": "H7lF9n36Rzqa-KfKcnGQMg", "index": "test-000057" }, "phase_execution": { "policy": "my_lifecycle3", "phase_definition": { "min_age": "0ms", "actions": { "rollover": { "max_age": "30s" } } }, "version": 3, "modified_date": "2018-10-15T13:21:41.576Z", "modified_date_in_millis": 1539609701576 } } } }