Skip to content

Commit e96446f

Browse files
benwtrentkcm
authored andcommitted
Allowing {index}/_xpack/rollup/data to accept comma delimited list (#34115)
* Allowing `{index}/_xpack/rollup/data` to accept comma delimited list * Address PR comments
1 parent a31f56d commit e96446f

File tree

2 files changed

+106
-1
lines changed

2 files changed

+106
-1
lines changed

x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/rest/RestGetRollupIndexCapsAction.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.elasticsearch.action.support.IndicesOptions;
99
import org.elasticsearch.client.node.NodeClient;
1010
import org.elasticsearch.common.ParseField;
11+
import org.elasticsearch.common.Strings;
1112
import org.elasticsearch.common.settings.Settings;
1213
import org.elasticsearch.rest.BaseRestHandler;
1314
import org.elasticsearch.rest.RestController;
@@ -27,7 +28,8 @@ public RestGetRollupIndexCapsAction(Settings settings, RestController controller
2728
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) {
2829
String index = restRequest.param(INDEX.getPreferredName());
2930
IndicesOptions options = IndicesOptions.fromRequest(restRequest, IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED);
30-
GetRollupIndexCapsAction.Request request = new GetRollupIndexCapsAction.Request(new String[]{index}, options);
31+
GetRollupIndexCapsAction.Request request =
32+
new GetRollupIndexCapsAction.Request(Strings.splitStringByCommaToArray(index), options);
3133
return channel -> client.execute(GetRollupIndexCapsAction.INSTANCE, request, new RestToXContentListener<>(channel));
3234
}
3335

x-pack/plugin/src/test/resources/rest-api-spec/test/rollup/get_rollup_index_caps.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,109 @@ setup:
288288
- agg: "max"
289289
- agg: "sum"
290290

291+
---
292+
"Verify job caps by rollup index comma delimited list":
293+
294+
- skip:
295+
version: " - 6.99.99"
296+
reason: "comma delimited index support was fixed in 7.0"
297+
298+
- do:
299+
headers:
300+
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
301+
xpack.rollup.put_job:
302+
id: foo2
303+
body: >
304+
{
305+
"index_pattern": "foo2",
306+
"rollup_index": "foo_rollup",
307+
"cron": "*/30 * * * * ?",
308+
"page_size" :10,
309+
"groups" : {
310+
"date_histogram": {
311+
"field": "the_field",
312+
"interval": "1h"
313+
}
314+
},
315+
"metrics": [
316+
{
317+
"field": "value_field",
318+
"metrics": ["min", "max", "sum"]
319+
}
320+
]
321+
}
322+
- do:
323+
headers:
324+
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
325+
xpack.rollup.put_job:
326+
id: foo3
327+
body: >
328+
{
329+
"index_pattern": "foo3",
330+
"rollup_index": "foo_rollup2",
331+
"cron": "*/30 * * * * ?",
332+
"page_size" :10,
333+
"groups" : {
334+
"date_histogram": {
335+
"field": "the_field",
336+
"interval": "1h"
337+
}
338+
},
339+
"metrics": [
340+
{
341+
"field": "value_field",
342+
"metrics": ["min", "max", "sum"]
343+
}
344+
]
345+
}
346+
347+
- do:
348+
xpack.rollup.get_rollup_index_caps:
349+
index: "foo_rollup2,foo_rollup"
350+
351+
- match:
352+
$body:
353+
foo_rollup:
354+
rollup_jobs:
355+
- job_id: "foo"
356+
rollup_index: "foo_rollup"
357+
index_pattern: "foo"
358+
fields:
359+
the_field:
360+
- agg: "date_histogram"
361+
interval: "1h"
362+
time_zone: "UTC"
363+
value_field:
364+
- agg: "min"
365+
- agg: "max"
366+
- agg: "sum"
367+
- job_id: "foo2"
368+
rollup_index: "foo_rollup"
369+
index_pattern: "foo2"
370+
fields:
371+
the_field:
372+
- agg: "date_histogram"
373+
interval: "1h"
374+
time_zone: "UTC"
375+
value_field:
376+
- agg: "min"
377+
- agg: "max"
378+
- agg: "sum"
379+
foo_rollup2:
380+
rollup_jobs:
381+
- job_id: "foo3"
382+
rollup_index: "foo_rollup2"
383+
index_pattern: "foo3"
384+
fields:
385+
the_field:
386+
- agg: "date_histogram"
387+
interval: "1h"
388+
time_zone: "UTC"
389+
value_field:
390+
- agg: "min"
391+
- agg: "max"
392+
- agg: "sum"
393+
291394
---
292395
"Verify index pattern":
293396

0 commit comments

Comments
 (0)