Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GET _cat/transforms API Issue #53643

Merged
merged 5 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.ml.rest.cat;

package org.elasticsearch.xpack.core.common.table;

import org.elasticsearch.common.Strings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.Table;
import org.elasticsearch.xpack.core.common.table.TableColumnAttributeBuilder;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.action.RestActionListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.Table;
import org.elasticsearch.xpack.core.common.table.TableColumnAttributeBuilder;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.Table;
import org.elasticsearch.xpack.core.common.table.TableColumnAttributeBuilder;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.rest.RestRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.Table;
import org.elasticsearch.xpack.core.common.table.TableColumnAttributeBuilder;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.rest.RestRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"transform.cat_transform":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transform.html"
},
"stability":"stable",
"url":{
"paths":[
{
"path":"/_cat/transform",
"methods":[
"GET"
]
},
{
"path":"/_cat/transform/{transform_id}",
"methods":[
"GET"
],
"parts":{
"transform_id":{
"type":"string",
"description":"The id of the transform for which to get stats. '_all' or '*' implies all transforms"
}
}
}
]
},
"params":{
"from":{
"type":"int",
"required":false,
"description":"skips a number of transform configs, defaults to 0"
},
"size":{
"type":"int",
"required":false,
"description":"specifies a max number of transforms to get, defaults to 100"
},
"allow_no_match":{
"type":"boolean",
"required":false,
"description":"Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)"
},
"format":{
"type":"string",
"description":"a short version of the Accept header, e.g. json, yaml"
},
"h":{
"type":"list",
"description":"Comma-separated list of column names to display"
},
"help":{
"type":"boolean",
"description":"Return help information",
"default":false
},
"s":{
"type":"list",
"description":"Comma-separated list of column names or column aliases to sort by"
},
"time":{
"type":"enum",
"description":"The unit in which to display time values",
"options":[
"d (Days)",
"h (Hours)",
"m (Minutes)",
"s (Seconds)",
"ms (Milliseconds)",
"micros (Microseconds)",
"nanos (Nanoseconds)"
]
},
"v":{
"type":"boolean",
"description":"Verbose mode. Display column headers",
"default":false
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
setup:
- skip:
features: headers
- do:
indices.create:
index: airline-data
body:
mappings:
properties:
time:
type: date
airline:
type: keyword
responsetime:
type: float
event_rate:
type: integer
- do:
indices.create:
index: airline-data-other
body:
mappings:
properties:
time:
type: date
airline:
type: keyword
responsetime:
type: float
event_rate:
type: integer
- do:
transform.put_transform:
transform_id: "airline-transform-stats"
body: >
{
"source": { "index": "airline-data" },
"dest": { "index": "airline-data-by-airline" },
"pivot": {
"group_by": { "airline": {"terms": {"field": "airline"}}},
"aggs": {"avg_response": {"avg": {"field": "responsetime"}}}
}
}

---
teardown:
- do:
transform.delete_transform:
transform_id: "airline-transform-stats"

---
"Test cat transform stats hiding headers":
- do:
transform.cat_transform:
transform_id: "airline-transform-stats"
- match:
$body: |
/^ #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
(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)+ $/

---
"Test cat transform stats with column selection":
- do:
transform.cat_transform:
transform_id: "airline-transform-stats"
v: true
h: id,version,source_index,dest_index,search_total,index_total,dt,cdtea,indexed_documents_exp_avg
- match:
$body: |
/^ 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
(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)+ $/


---
"Test cat transform stats with batch transform":
- do:
transform.put_transform:
transform_id: "airline-transform-batch"
body: >
{
"source": {
"index": ["airline-data", "airline-data-other"],
"query": {"bool":{"filter":{"term":{"airline":"foo"}}}}
},
"dest": { "index": "airline-data-by-airline-batch" },
"pivot": {
"group_by": { "airline": {"terms": {"field": "airline"}}},
"aggs": {"avg_response": {"avg": {"field": "responsetime"}}}
},
"description": "description"
}
- do:
transform.cat_transform:
transform_id: "airline-transform-batch"
v: true
- match:
$body: |
/^ 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
(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)+ $/
- do:
transform.delete_transform:
transform_id: "airline-transform-batch"

---
"Test cat transform stats with continuous transform":
- do:
transform.put_transform:
transform_id: "airline-transform-continuous"
body: >
{
"source": {
"index": ["airline-data", "airline-data-other"],
"query": {"bool":{"filter":{"term":{"airline":"foo"}}}}
},
"dest": { "index": "airline-data-by-airline-continuous" },
"frequency": "10s",
"pivot": {
"group_by": { "airline": {"terms": {"field": "airline"}}},
"aggs": {"avg_response": {"avg": {"field": "responsetime"}}}
},
"description": "description",
"sync": {
"time": {
"field": "time"
}
}
}
- do:
transform.cat_transform:
transform_id: "airline-transform-continuous"
v: true
- match:
$body: |
/^ 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
(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)+ $/
- do:
transform.delete_transform:
transform_id: "airline-transform-continuous"
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import org.elasticsearch.xpack.transform.persistence.IndexBasedTransformConfigManager;
import org.elasticsearch.xpack.transform.persistence.TransformConfigManager;
import org.elasticsearch.xpack.transform.persistence.TransformInternalIndex;
import org.elasticsearch.xpack.transform.rest.action.RestCatTransformAction;
import org.elasticsearch.xpack.transform.rest.action.RestDeleteTransformAction;
import org.elasticsearch.xpack.transform.rest.action.RestGetTransformAction;
import org.elasticsearch.xpack.transform.rest.action.RestGetTransformStatsAction;
Expand Down Expand Up @@ -170,6 +171,7 @@ public List<RestHandler> getRestHandlers(
new RestGetTransformStatsAction(),
new RestPreviewTransformAction(),
new RestUpdateTransformAction(),
new RestCatTransformAction(),

// deprecated endpoints, to be removed for 8.0.0
new RestPutTransformActionDeprecated(),
Expand Down
Loading