Skip to content

Commit 110ff6c

Browse files
authored
Create GET _cat/transforms API Issue (#53643)
Adds new` _cat/transform` and `_cat/transform/{transform_id}` endpoints.
1 parent de9e44f commit 110ff6c

File tree

9 files changed

+481
-1
lines changed

9 files changed

+481
-1
lines changed

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/TableColumnAttributeBuilder.java renamed to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/common/table/TableColumnAttributeBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
package org.elasticsearch.xpack.ml.rest.cat;
76

7+
package org.elasticsearch.xpack.core.common.table;
88

99
import org.elasticsearch.common.Strings;
1010

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatDataFrameAnalyticsAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.elasticsearch.cluster.node.DiscoveryNode;
1111
import org.elasticsearch.common.Strings;
1212
import org.elasticsearch.common.Table;
13+
import org.elasticsearch.xpack.core.common.table.TableColumnAttributeBuilder;
1314
import org.elasticsearch.rest.RestRequest;
1415
import org.elasticsearch.rest.RestResponse;
1516
import org.elasticsearch.rest.action.RestActionListener;

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatDatafeedsAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.elasticsearch.cluster.node.DiscoveryNode;
1010
import org.elasticsearch.common.Strings;
1111
import org.elasticsearch.common.Table;
12+
import org.elasticsearch.xpack.core.common.table.TableColumnAttributeBuilder;
1213
import org.elasticsearch.common.unit.TimeValue;
1314
import org.elasticsearch.rest.RestRequest;
1415
import org.elasticsearch.rest.RestResponse;

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatJobsAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.elasticsearch.cluster.node.DiscoveryNode;
1111
import org.elasticsearch.common.Strings;
1212
import org.elasticsearch.common.Table;
13+
import org.elasticsearch.xpack.core.common.table.TableColumnAttributeBuilder;
1314
import org.elasticsearch.common.unit.ByteSizeValue;
1415
import org.elasticsearch.common.unit.TimeValue;
1516
import org.elasticsearch.rest.RestRequest;

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/cat/RestCatTrainedModelsAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.elasticsearch.cluster.metadata.MetaData;
1313
import org.elasticsearch.common.Strings;
1414
import org.elasticsearch.common.Table;
15+
import org.elasticsearch.xpack.core.common.table.TableColumnAttributeBuilder;
1516
import org.elasticsearch.common.unit.ByteSizeValue;
1617
import org.elasticsearch.common.unit.TimeValue;
1718
import org.elasticsearch.rest.RestRequest;
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"transform.cat_transform":{
3+
"documentation":{
4+
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transform.html"
5+
},
6+
"stability":"stable",
7+
"url":{
8+
"paths":[
9+
{
10+
"path":"/_cat/transform",
11+
"methods":[
12+
"GET"
13+
]
14+
},
15+
{
16+
"path":"/_cat/transform/{transform_id}",
17+
"methods":[
18+
"GET"
19+
],
20+
"parts":{
21+
"transform_id":{
22+
"type":"string",
23+
"description":"The id of the transform for which to get stats. '_all' or '*' implies all transforms"
24+
}
25+
}
26+
}
27+
]
28+
},
29+
"params":{
30+
"from":{
31+
"type":"int",
32+
"required":false,
33+
"description":"skips a number of transform configs, defaults to 0"
34+
},
35+
"size":{
36+
"type":"int",
37+
"required":false,
38+
"description":"specifies a max number of transforms to get, defaults to 100"
39+
},
40+
"allow_no_match":{
41+
"type":"boolean",
42+
"required":false,
43+
"description":"Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)"
44+
},
45+
"format":{
46+
"type":"string",
47+
"description":"a short version of the Accept header, e.g. json, yaml"
48+
},
49+
"h":{
50+
"type":"list",
51+
"description":"Comma-separated list of column names to display"
52+
},
53+
"help":{
54+
"type":"boolean",
55+
"description":"Return help information",
56+
"default":false
57+
},
58+
"s":{
59+
"type":"list",
60+
"description":"Comma-separated list of column names or column aliases to sort by"
61+
},
62+
"time":{
63+
"type":"enum",
64+
"description":"The unit in which to display time values",
65+
"options":[
66+
"d (Days)",
67+
"h (Hours)",
68+
"m (Minutes)",
69+
"s (Seconds)",
70+
"ms (Milliseconds)",
71+
"micros (Microseconds)",
72+
"nanos (Nanoseconds)"
73+
]
74+
},
75+
"v":{
76+
"type":"boolean",
77+
"description":"Verbose mode. Display column headers",
78+
"default":false
79+
}
80+
}
81+
}
82+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
setup:
2+
- skip:
3+
features: headers
4+
- do:
5+
indices.create:
6+
index: airline-data
7+
body:
8+
mappings:
9+
properties:
10+
time:
11+
type: date
12+
airline:
13+
type: keyword
14+
responsetime:
15+
type: float
16+
event_rate:
17+
type: integer
18+
- do:
19+
indices.create:
20+
index: airline-data-other
21+
body:
22+
mappings:
23+
properties:
24+
time:
25+
type: date
26+
airline:
27+
type: keyword
28+
responsetime:
29+
type: float
30+
event_rate:
31+
type: integer
32+
- do:
33+
transform.put_transform:
34+
transform_id: "airline-transform-stats"
35+
body: >
36+
{
37+
"source": { "index": "airline-data" },
38+
"dest": { "index": "airline-data-by-airline" },
39+
"pivot": {
40+
"group_by": { "airline": {"terms": {"field": "airline"}}},
41+
"aggs": {"avg_response": {"avg": {"field": "responsetime"}}}
42+
}
43+
}
44+
45+
---
46+
teardown:
47+
- do:
48+
transform.delete_transform:
49+
transform_id: "airline-transform-stats"
50+
51+
---
52+
"Test cat transform stats hiding headers":
53+
- do:
54+
transform.cat_transform:
55+
transform_id: "airline-transform-stats"
56+
- match:
57+
$body: |
58+
/^ #id \s+ create_time \s+ version \s+ source_index \s+ dest_index \s+ pipeline \s+ transform_type \s+ frequency \s+ max_page_search_size \s+ state \n
59+
(airline\-transform\-stats \s+ [^\s]+ \s+ [^\s]+ \s+ airline-data \s+ airline-data-by-airline \s+ \s+ batch \s+ 1m \s+ 500 \s+ STOPPED \n)+ $/
60+
61+
---
62+
"Test cat transform stats with column selection":
63+
- do:
64+
transform.cat_transform:
65+
transform_id: "airline-transform-stats"
66+
v: true
67+
h: id,version,source_index,dest_index,search_total,index_total,dt,cdtea,indexed_documents_exp_avg
68+
- match:
69+
$body: |
70+
/^ id \s+ version \s+ source_index \s+ dest_index \s+ search_total \s+ index_total \s+ dt \s+ cdtea \s+ indexed_documents_exp_avg \n
71+
(airline\-transform-stats \s+ [^\s]+ \s+ airline-data \s+ airline-data-by-airline \s+ 0 \s+ 0 \s+ 0 \s+ 0.0 \s+ 0.0 \n)+ $/
72+
73+
74+
---
75+
"Test cat transform stats with batch transform":
76+
- do:
77+
transform.put_transform:
78+
transform_id: "airline-transform-batch"
79+
body: >
80+
{
81+
"source": {
82+
"index": ["airline-data", "airline-data-other"],
83+
"query": {"bool":{"filter":{"term":{"airline":"foo"}}}}
84+
},
85+
"dest": { "index": "airline-data-by-airline-batch" },
86+
"pivot": {
87+
"group_by": { "airline": {"terms": {"field": "airline"}}},
88+
"aggs": {"avg_response": {"avg": {"field": "responsetime"}}}
89+
},
90+
"description": "description"
91+
}
92+
- do:
93+
transform.cat_transform:
94+
transform_id: "airline-transform-batch"
95+
v: true
96+
- match:
97+
$body: |
98+
/^ id \s+ create_time \s+ version \s+ source_index \s+ dest_index \s+ pipeline \s+ description \s+ transform_type \s+ frequency \s+ max_page_search_size \s+ state \n
99+
(airline\-transform\-batch \s+ [^\s]+ \s+ [^\s]+ \s+ airline-data,airline-data-other \s+ airline-data-by-airline-batch \s+ \s+ description \s+ batch \s+ 1m \s+ 500 \s+ STOPPED \n)+ $/
100+
- do:
101+
transform.delete_transform:
102+
transform_id: "airline-transform-batch"
103+
104+
---
105+
"Test cat transform stats with continuous transform":
106+
- do:
107+
transform.put_transform:
108+
transform_id: "airline-transform-continuous"
109+
body: >
110+
{
111+
"source": {
112+
"index": ["airline-data", "airline-data-other"],
113+
"query": {"bool":{"filter":{"term":{"airline":"foo"}}}}
114+
},
115+
"dest": { "index": "airline-data-by-airline-continuous" },
116+
"frequency": "10s",
117+
"pivot": {
118+
"group_by": { "airline": {"terms": {"field": "airline"}}},
119+
"aggs": {"avg_response": {"avg": {"field": "responsetime"}}}
120+
},
121+
"description": "description",
122+
"sync": {
123+
"time": {
124+
"field": "time"
125+
}
126+
}
127+
}
128+
- do:
129+
transform.cat_transform:
130+
transform_id: "airline-transform-continuous"
131+
v: true
132+
- match:
133+
$body: |
134+
/^ id \s+ create_time \s+ version \s+ source_index \s+ dest_index \s+ pipeline \s+ description \s+ transform_type \s+ frequency \s+ max_page_search_size \s+ state \n
135+
(airline\-transform\-continuous \s+ [^\s]+ \s+ [^\s]+ \s+ airline-data,airline-data-other \s+ airline-data-by-airline-continuous \s+ \s+ description \s+ continuous \s+ 10s \s+ 500 \s+ STOPPED \n)+ $/
136+
- do:
137+
transform.delete_transform:
138+
transform_id: "airline-transform-continuous"

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
import org.elasticsearch.xpack.transform.persistence.IndexBasedTransformConfigManager;
8989
import org.elasticsearch.xpack.transform.persistence.TransformConfigManager;
9090
import org.elasticsearch.xpack.transform.persistence.TransformInternalIndex;
91+
import org.elasticsearch.xpack.transform.rest.action.RestCatTransformAction;
9192
import org.elasticsearch.xpack.transform.rest.action.RestDeleteTransformAction;
9293
import org.elasticsearch.xpack.transform.rest.action.RestGetTransformAction;
9394
import org.elasticsearch.xpack.transform.rest.action.RestGetTransformStatsAction;
@@ -201,6 +202,7 @@ public List<RestHandler> getRestHandlers(
201202
new RestGetTransformStatsAction(),
202203
new RestPreviewTransformAction(),
203204
new RestUpdateTransformAction(),
205+
new RestCatTransformAction(),
204206

205207
// deprecated endpoints, to be removed for 8.0.0
206208
new RestPutTransformActionDeprecated(),

0 commit comments

Comments
 (0)