解释生命周期 API
编辑解释生命周期 API
编辑检索一个或多个索引的当前生命周期状态。对于数据流,API 检索流的后备索引的当前生命周期状态。
请求
编辑GET <target>/_ilm/explain
先决条件
编辑- 如果启用了 Elasticsearch 安全功能,您必须对被管理的索引具有
view_index_metadata
或manage_ilm
或两者兼有的权限才能使用此 API。有关详细信息,请参阅安全权限。
描述
编辑检索有关索引当前生命周期状态的信息,例如当前正在执行的阶段、操作和步骤。显示索引何时进入每个阶段、正在运行的阶段的定义以及有关任何故障的信息。
路径参数
编辑-
<target>
- (必需,字符串) 要定位的数据流、索引和别名的逗号分隔列表。支持通配符 (
*
)。要定位所有数据流和索引,请使用*
或_all
。
查询参数
编辑-
only_managed
- (可选,布尔值) 筛选返回的索引,只返回由 ILM 管理的索引。
-
only_errors
- (可选,布尔值) 筛选返回的索引,只返回由 ILM 管理且处于错误状态的索引,原因是在执行策略时遇到错误,或者尝试使用不存在的策略。
-
master_timeout
- (可选,时间单位) 等待主节点的时间段。如果在超时到期之前主节点不可用,则请求失败并返回错误。默认为
30s
。也可以设置为-1
以表示请求永不超时。
示例
编辑以下示例检索 my-index-000001
的生命周期状态
resp = client.ilm.explain_lifecycle( index="my-index-000001", human=True, ) print(resp)
response = client.ilm.explain_lifecycle( index: 'my-index-000001', human: true ) puts response
const response = await client.ilm.explainLifecycle({ index: "my-index-000001", human: "true", }); console.log(response);
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" }, "previous_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 } } } }