Skip to content

Commit 4e1f350

Browse files
committed
add data_stream_stats
1 parent 7064c9c commit 4e1f350

File tree

3 files changed

+158
-2
lines changed

3 files changed

+158
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ npm run docs:dev
918918
- :heavy_check_mark: 删除数据流 [:link:](https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/delete_data_stream)
919919
- :heavy_check_mark: 获取数据流 [:link:](https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/get_data_stream)
920920
- :heavy_check_mark: 迁移数据流 [:link:](https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/migrate_to_data_stream)
921-
- Data stream stats
921+
- :heavy_check_mark: 数据流统计 [:link:](https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/data_stream_stats)
922922
- Promote data stream
923923
- :heavy_check_mark: 文档 API [:link:](https://elasticsearch.bookhub.tech/rest_apis/document_apis/)
924924
- :heavy_check_mark: 读写 API [:link:](https://elasticsearch.bookhub.tech/rest_apis/document_apis/replication)
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# 数据流统计 API
2+
3+
检索一个或多个[数据流](/data_streams)的统计数据。
4+
5+
```bash
6+
GET /_data_stream/my-data-stream/_stats
7+
```
8+
9+
## 前置条件
10+
11+
- 如果 Elasticsearch 安全特性启用,你必须有 `monitor``manage`[索引权限](/secure_the_elastic_statck/user_authorization/security_privileges#索引权限)
12+
13+
## 请求
14+
15+
`GET /_data_stream/<data-stream>/_stats`
16+
17+
## 路径参数
18+
19+
- `<data-stream>`
20+
21+
(可选,字符串) 用于限制请求的数据流的逗号分隔列表。支持通配符表达式 (`*`)。
22+
23+
要以集群中的所有数据流为目标,请省略此参数或使用 `*`
24+
25+
## 查询参数
26+
27+
- `expand_wildcards`
28+
29+
(可选,字符串)通配符模式可以匹配的数据流类型。支持逗号分隔值,例如 `open,hidden`。有效值为:
30+
31+
- `all``hidden`
32+
33+
匹配任何数据流或索引,包括[隐藏的](/rest_apis/api_conventions/multi_target_syntax#隐藏数据流和索引)。
34+
35+
- `open``closed`
36+
37+
匹配任何非隐藏的数据流。无法关闭 Data Streams。
38+
39+
- `none`
40+
41+
不接受通配符模式。
42+
43+
默认为 `open`
44+
45+
- `human`
46+
47+
(可选,布尔值) 如果为 `true`,则响应会包含以人类可读[字节值](/rest_apis/api_conventions#字节大小单位)表示的统计数据。默认为 `false`
48+
49+
## 响应体
50+
51+
- `_shards`
52+
53+
(对象)包含试图执行请求的分片的信息。
54+
55+
- `_shards` 属性
56+
57+
- `total`
58+
59+
(整数)尝试执行请求的分片总数。
60+
61+
- `successful`
62+
63+
(整数)成功执行请求的分片数。
64+
65+
- `failed`
66+
67+
(整数)未能执行请求的分片数量。
68+
69+
- `data_stream_count`
70+
71+
(整数)所选数据流的总数。
72+
73+
- `backing_indices`
74+
75+
(整数)所选数据流的备份索引总数。
76+
77+
- `total_store_size`
78+
79+
([字节值](/rest_apis/api_conventions#字节大小单位))所选数据流的所有分块的总大小。只有当 `human` 查询参数为 `true` 时,才会包含此属性。
80+
81+
- `total_store_size_bytes`
82+
83+
(整数)所选数据流所有分块的总大小(字节)。
84+
85+
- `data_streams`
86+
87+
(对象数组) 包含所选数据流的统计数据。
88+
89+
- `data_streams` 对象属性
90+
91+
- `data_stream`
92+
93+
(字符串) 数据流的名称。
94+
95+
- `backing_indices`
96+
97+
(整数)数据流的当前后备索引数。
98+
99+
- `store_size`
100+
101+
([字节值](/rest_apis/api_conventions#字节大小单位))数据流后备索引所有分片的总大小。只有当 `human` 查询参数为 `true` 时,才会返回该参数。
102+
103+
- `store_size_bytes`
104+
105+
(整数)数据流后备索引所有分片的总大小(以字节为单位)。
106+
107+
- `maximum_timestamp`
108+
109+
(整数) 数据流的最高 `@timestamp` 值,转换为 [Unix epoch](https://en.wikipedia.org/wiki/Unix_time)以来的毫秒数。
110+
111+
:::note 提示
112+
如果满足以下一个或多个条件,数据流中的 `@timestamp` 值可能高于此值:
113+
- 数据流包含已关闭的后备索引。
114+
- 生成时间较短的备份索引包含较高的 `@timestamp` 值。
115+
:::
116+
117+
## 示例
118+
119+
```bash
120+
GET /_data_stream/my-data-stream*/_stats?human=true
121+
```
122+
123+
API 返回以下响应。
124+
125+
```json
126+
{
127+
"_shards": {
128+
"total": 10,
129+
"successful": 5,
130+
"failed": 0
131+
},
132+
"data_stream_count": 2,
133+
"backing_indices": 5,
134+
"total_store_size": "7kb",
135+
"total_store_size_bytes": 7268,
136+
"data_streams": [
137+
{
138+
"data_stream": "my-data-stream",
139+
"backing_indices": 3,
140+
"store_size": "3.7kb",
141+
"store_size_bytes": 3772,
142+
"maximum_timestamp": 1607512028000
143+
},
144+
{
145+
"data_stream": "my-data-stream-two",
146+
"backing_indices": 2,
147+
"store_size": "3.4kb",
148+
"store_size_bytes": 3496,
149+
"maximum_timestamp": 1607425567000
150+
}
151+
]
152+
}
153+
```
154+
155+
> [原文链接](https://www.elastic.co/guide/en/elasticsearch/reference/current/data-stream-stats-api.html)

sidebars.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ const sidebars = {
159159
'rest_apis/data_stream_apis/create_data_stream',
160160
'rest_apis/data_stream_apis/delete_data_stream',
161161
'rest_apis/data_stream_apis/get_data_stream',
162-
'rest_apis/data_stream_apis/migrate_to_data_stream'
162+
'rest_apis/data_stream_apis/migrate_to_data_stream',
163+
'rest_apis/data_stream_apis/data_stream_stats'
163164
]
164165
},
165166
{

0 commit comments

Comments
 (0)