Skip to content

Commit 4059939

Browse files
committed
add delete_data_stream_lifecycle,explain_data_stream_lifecycle
1 parent 091bf49 commit 4059939

File tree

4 files changed

+158
-0
lines changed

4 files changed

+158
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,8 @@ npm run docs:dev
923923
- :heavy_check_mark: 修改数据流 [:link:](https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/modify_data_stream)
924924
- :heavy_check_mark: 设置数据流生命周期 [:link:](https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/put_data_stream_lifecycle)
925925
- :heavy_check_mark: 获取数据流的生命周期 [:link:](https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/get_data_stream_lifecycle)
926+
- :heavy_check_mark: 删除数据流的生命周期 [:link:](https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/delete_data_stream_lifecycle)
927+
- :heavy_check_mark: 解释数据流的生命周期 [:link:](https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/explain_data_stream_lifecycle)
926928
- :heavy_check_mark: 文档 API [:link:](https://elasticsearch.bookhub.tech/rest_apis/document_apis/)
927929
- :heavy_check_mark: 读写 API [:link:](https://elasticsearch.bookhub.tech/rest_apis/document_apis/replication)
928930
- :heavy_check_mark: 索引 API [:link:](https://elasticsearch.bookhub.tech/rest_apis/document_apis/docs_index)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# 删除数据流生命周期
2+
3+
:::info 新 API 参考
4+
有关最新 API 的详细信息,参阅[数据流 API](https://www.elastic.co/docs/api/doc/elasticsearch/v8/group/endpoint-data-stream)
5+
:::
6+
7+
从一组数据流中删除[生命周期](/data_streams/data_stream_lifecycle)
8+
9+
## 前置条件
10+
11+
- 如果 Elasticsearch 安全特性启用,你必须有 `manage_data_stream_lifecycle` 的索引权限。更多信息,参阅[安全权限](/secure_the_elastic_statck/user_authorization/security_privileges)
12+
13+
## 请求
14+
15+
`DELETE _data_stream/<data-stream>/_lifecycle`
16+
17+
## 描述
18+
19+
从指定的数据流中删除生命周期。如果提供了多个数据流,但其中只要有一个不存在,那么删除所有数据流中的生命周期都将失败,API 将以 `404` 响应。
20+
21+
## 路径参数
22+
23+
- `<data-stream>`
24+
25+
(必需,字符串)要删除的数据流的逗号分隔列表。支持通配符 (`*`) 表达式。要针对所有数据流,请使用 `*``_all`
26+
27+
## 查询参数
28+
29+
- `expand_wildcards`
30+
31+
(可选,字符串)通配符模式可以匹配的数据流类型。支持逗号分隔值,例如 `open,hidden`。有效值为:
32+
33+
- `all``hidden`
34+
35+
匹配任何数据流或索引,包括[隐藏的](/rest_apis/api_conventions/multi_target_syntax#隐藏数据流和索引)。
36+
37+
- `open``closed`
38+
39+
匹配任何非隐藏的数据流。无法关闭 Data Streams。
40+
41+
- `none`
42+
43+
不接受通配符模式。
44+
45+
默认为 `open`
46+
47+
## 示例
48+
49+
下面的示例删除了 `my-data-stream` 的生命周期:
50+
51+
```bash
52+
DELETE _data_stream/my-data-stream/_lifecycle
53+
```
54+
55+
从所有选定数据流中成功删除策略后,会收到以下结果:
56+
57+
```json
58+
{
59+
"acknowledged": true
60+
}
61+
```
62+
63+
> [原文链接](https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams-delete-lifecycle.html)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# 解释数据流生命周期
2+
3+
:::info 新 API 参考
4+
有关最新 API 的详细信息,参阅[数据流 API](https://www.elastic.co/docs/api/doc/elasticsearch/v8/group/endpoint-data-stream)
5+
:::
6+
7+
读取一个或多个数据流后备索引的当前[数据流生命周期](/data_streams/data_stream_lifecycle)状态。
8+
9+
## 前置条件
10+
11+
- 如果 Elasticsearch 安全特性启用,你必须有 `manage_data_stream_lifecycle` 的索引权限或 `view_index_metadata` 索引权限来使用此 API。更多信息,参阅[安全权限](/secure_the_elastic_statck/user_authorization/security_privileges)
12+
13+
## 请求
14+
15+
`GET <target>/_lifecycle/explain`
16+
17+
## 描述
18+
19+
读取有关索引或数据流当前数据流生命周期状态的信息,如创建索引以来的时间、翻转以来的时间、管理索引的生命周期配置,或 Elasticsearch 在生命周期执行期间可能遇到的任何错误。
20+
21+
## 路径参数
22+
23+
- `<target>`
24+
25+
(必需,字符串) 用逗号分隔的索引或数据流列表。
26+
27+
## 查询参数
28+
29+
- `include_defaults`
30+
31+
(可选,布尔值)包含与目标生命周期相关的默认配置。默认为 `false`
32+
33+
- `master_timeout`
34+
35+
(可选,[时间单位](/rest_apis/api_convention/common_options#时间单位))等待主节点的时间。如果在超时前主节点不可用,则请求失败并返回错误。默认为 `30s`。也可以设置为 `-1`,表示请求永不超时。
36+
37+
## 示例
38+
39+
如果要检索数据流中所有后备索引的生命周期状态,可以使用数据流名称。为简单起见,以下示例检索了一个后备索引 `.ds-metrics-2023.03.22-000001` 的生命周期状态:
40+
41+
```bash
42+
GET .ds-metrics-2023.03.22-000001/_lifecycle/explain
43+
```
44+
45+
如果该索引由数据流生命周期管理,则解释将显示 `managed_by_lifecycle` 字段设置为 `true`,响应的其余部分将包含有关该索引生命周期执行状态的信息:
46+
47+
```json
48+
{
49+
"indices": {
50+
".ds-metrics-2023.03.22-000001": {
51+
"index" : ".ds-metrics-2023.03.22-000001",
52+
"managed_by_lifecycle" : true,
53+
"index_creation_date_millis" : 1679475563571,
54+
"time_since_index_creation" : "843ms",
55+
"rollover_date_millis" : 1679475564293,
56+
"time_since_rollover" : "121ms",
57+
"lifecycle" : { },
58+
"generation_time" : "121ms"
59+
}
60+
}
61+
```
62+
1. `"managed_by_lifecycle" : true`:显示索引是否由数据流生命周期管理。如果索引不是由数据流生命周期管理,则不会显示其他字段
63+
2. `"index_creation_date_millis" : 1679475563571`:创建索引的时间,该时间戳用于确定何时翻转
64+
3. `"time_since_index_creation" : "843ms"`:索引创建后的时间(用于通过 `max_age` 计算何时翻转索引)
65+
4. `"rollover_date_millis" : 1679475564293`:索引翻转的时间。如果索引没有滚动,则不会显示。
66+
5. `"time_since_rollover" : "121ms"`:翻转后的时间。如果索引没有滚动,则不会显示。
67+
6. `"lifecycle" : { }`:适用于该索引的生命周期配置(在父数据流中进行了配置)
68+
7. `"generation_time" : "121ms"`:索引的生成时间表示索引开始进入生命周期中用户可配置/业务特定部分(如保留)的时间。如果存在 `generation_time`,则从该日期开始计算生成时间;如果存在翻转日期,则从该日期开始计算生成时间;如果其他两个日期都不存在,则从创建日期开始计算生成时间。如果该索引是写入索引,则不会报告 `generation_time`,因为它不符合保留或生命周期其他部分的条件。
69+
70+
`explain` 还会报告与目标索引生命周期执行相关的任何错误:
71+
72+
```json
73+
{
74+
"indices": {
75+
".ds-metrics-2023.03.22-000001": {
76+
"index" : ".ds-metrics-2023.03.22-000001",
77+
"managed_by_lifecycle" : true,
78+
"index_creation_date_millis" : 1679475563571,
79+
"time_since_index_creation" : "843ms",
80+
"lifecycle" : {
81+
"enabled": true
82+
},
83+
"error": "{\"type\":\"validation_exception\",\"reason\":\"Validation Failed: 1: this action would add [2] shards, but this cluster
84+
currently has [4]/[3] maximum normal shards open;\"}"
85+
}
86+
}
87+
```
88+
89+
1. `"error":`:由于集群中允许的分片数量限制,无法翻转目标索引。
90+
91+
> [原文链接](https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams-explain-lifecycle.html)

sidebars.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ const sidebars = {
165165
'rest_apis/data_stream_apis/modify_data_stream',
166166
'rest_apis/data_stream_apis/put_data_stream_lifecycle',
167167
'rest_apis/data_stream_apis/get_data_stream_lifecycle',
168+
'rest_apis/data_stream_apis/delete_data_stream_lifecycle',
169+
'rest_apis/data_stream_apis/explain_data_stream_lifecycle'
168170
]
169171
},
170172
{

0 commit comments

Comments
 (0)