Convert `jobs` namespace to `anomaly_detectors` (elastic/elasticsearch#513)
This also shuffles results under /anomaly_detectors/. Note: the cluster state still refers to "jobs" which should probably be fixed in a separate PR Original commit: elastic/x-pack-elasticsearch@c9e634621c
This commit is contained in:
parent
a85dfcd91f
commit
30bbbf0f78
|
@ -22,6 +22,7 @@ import org.elasticsearch.cluster.block.ClusterBlockException;
|
|||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
@ -61,6 +62,8 @@ public class OpenJobAction extends Action<OpenJobAction.Request, OpenJobAction.R
|
|||
|
||||
public static class Request extends AcknowledgedRequest<Request> {
|
||||
|
||||
public static final ParseField OPEN_TIMEOUT = new ParseField("open_timeout");
|
||||
|
||||
private String jobId;
|
||||
private boolean ignoreDowntime;
|
||||
private TimeValue openTimeout = TimeValue.timeValueMinutes(30);
|
||||
|
|
|
@ -28,7 +28,7 @@ public class RestCloseJobAction extends BaseRestHandler {
|
|||
super(settings);
|
||||
this.closeJobAction = closeJobAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH
|
||||
+ "jobs/{" + Job.ID.getPreferredName() + "}/_close", this);
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_close", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,8 @@ public class RestDeleteJobAction extends BaseRestHandler {
|
|||
public RestDeleteJobAction(Settings settings, RestController controller, DeleteJobAction.TransportAction transportDeleteJobAction) {
|
||||
super(settings);
|
||||
this.transportDeleteJobAction = transportDeleteJobAction;
|
||||
controller.registerHandler(RestRequest.Method.DELETE, PrelertPlugin.BASE_PATH + "jobs/{" + Job.ID.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.DELETE, PrelertPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,8 +36,8 @@ public class RestFlushJobAction extends BaseRestHandler {
|
|||
FlushJobAction.TransportAction flushJobAction) {
|
||||
super(settings);
|
||||
this.flushJobAction = flushJobAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH + "jobs/{" + Job.ID.getPreferredName() + "}/_flush",
|
||||
this);
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_flush", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,18 +35,18 @@ public class RestGetJobsAction extends BaseRestHandler {
|
|||
this.transportGetJobAction = transportGetJobAction;
|
||||
|
||||
// GETs
|
||||
controller.registerHandler(RestRequest.Method.GET, PrelertPlugin.BASE_PATH + "jobs/{" + Job.ID.getPreferredName() + "}/_stats",
|
||||
this);
|
||||
controller.registerHandler(RestRequest.Method.GET, PrelertPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_stats", this);
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
PrelertPlugin.BASE_PATH + "jobs/{" + Job.ID.getPreferredName() + "}/_stats/{metric}", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, PrelertPlugin.BASE_PATH + "jobs/_stats", this);
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_stats/{metric}", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, PrelertPlugin.BASE_PATH + "anomaly_detectors/_stats", this);
|
||||
|
||||
// POSTs
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH + "jobs/{" + Job.ID.getPreferredName() + "}/_stats",
|
||||
this);
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_stats", this);
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
PrelertPlugin.BASE_PATH + "jobs/{" + Job.ID.getPreferredName() + "}/_stats/{metric}", this);
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH + "jobs/_stats", this);
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_stats/{metric}", this);
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH + "anomaly_detectors/_stats", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,8 +30,8 @@ public class RestJobDataAction extends BaseRestHandler {
|
|||
public RestJobDataAction(Settings settings, RestController controller, JobDataAction.TransportAction transportPostDataAction) {
|
||||
super(settings);
|
||||
this.transportPostDataAction = transportPostDataAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH + "jobs/{" + Job.ID.getPreferredName() + "}/data",
|
||||
this);
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/data", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.elasticsearch.rest.RestController;
|
|||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.AcknowledgedRestListener;
|
||||
import org.elasticsearch.xpack.prelert.PrelertPlugin;
|
||||
import org.elasticsearch.xpack.prelert.action.JobDataAction;
|
||||
import org.elasticsearch.xpack.prelert.action.OpenJobAction;
|
||||
import org.elasticsearch.xpack.prelert.job.Job;
|
||||
|
||||
|
@ -27,16 +28,18 @@ public class RestOpenJobAction extends BaseRestHandler {
|
|||
public RestOpenJobAction(Settings settings, RestController controller, OpenJobAction.TransportAction openJobAction) {
|
||||
super(settings);
|
||||
this.openJobAction = openJobAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH + "jobs/{" + Job.ID.getPreferredName() + "}/_open",
|
||||
this);
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_open", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
OpenJobAction.Request request = new OpenJobAction.Request(restRequest.param(Job.ID.getPreferredName()));
|
||||
request.setIgnoreDowntime(restRequest.paramAsBoolean("ignore_downtime", false));
|
||||
if (restRequest.hasParam("open_timeout")) {
|
||||
request.setOpenTimeout(TimeValue.parseTimeValue(restRequest.param("open_timeout"), "open_timeout"));
|
||||
request.setIgnoreDowntime(restRequest.paramAsBoolean(JobDataAction.Request.IGNORE_DOWNTIME.getPreferredName(), false));
|
||||
if (restRequest.hasParam(OpenJobAction.Request.OPEN_TIMEOUT.getPreferredName())) {
|
||||
request.setOpenTimeout(TimeValue.parseTimeValue(
|
||||
restRequest.param(OpenJobAction.Request.OPEN_TIMEOUT.getPreferredName()),
|
||||
OpenJobAction.Request.OPEN_TIMEOUT.getPreferredName()));
|
||||
}
|
||||
return channel -> openJobAction.execute(request, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class RestPutJobAction extends BaseRestHandler {
|
|||
public RestPutJobAction(Settings settings, RestController controller, PutJobAction.TransportAction transportPutJobAction) {
|
||||
super(settings);
|
||||
this.transportPutJobAction = transportPutJobAction;
|
||||
controller.registerHandler(RestRequest.Method.PUT, PrelertPlugin.BASE_PATH + "jobs", this);
|
||||
controller.registerHandler(RestRequest.Method.PUT, PrelertPlugin.BASE_PATH + "anomaly_detectors", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,8 +28,8 @@ public class RestDeleteModelSnapshotAction extends BaseRestHandler {
|
|||
DeleteModelSnapshotAction.TransportAction transportAction) {
|
||||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.DELETE, PrelertPlugin.BASE_PATH + "modelsnapshots/{"
|
||||
+ Job.ID.getPreferredName() + "}/{" + ModelSnapshot.SNAPSHOT_ID.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.DELETE, PrelertPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/modelsnapshots/{" + ModelSnapshot.SNAPSHOT_ID.getPreferredName() + "}", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,11 +41,11 @@ public class RestGetModelSnapshotsAction extends BaseRestHandler {
|
|||
GetModelSnapshotsAction.TransportAction transportGetModelSnapshotsAction) {
|
||||
super(settings);
|
||||
this.transportGetModelSnapshotsAction = transportGetModelSnapshotsAction;
|
||||
controller.registerHandler(RestRequest.Method.GET, PrelertPlugin.BASE_PATH + "modelsnapshots/{"
|
||||
+ Job.ID.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, PrelertPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/modelsnapshots/", this);
|
||||
// endpoints that support body parameters must also accept POST
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH + "modelsnapshots/{"
|
||||
+ Job.ID.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/modelsnapshots/", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,8 +34,8 @@ public class RestPutModelSnapshotDescriptionAction extends BaseRestHandler {
|
|||
this.transportAction = transportAction;
|
||||
|
||||
// NORELEASE: should be a POST action
|
||||
controller.registerHandler(RestRequest.Method.PUT, PrelertPlugin.BASE_PATH + "modelsnapshots/{"
|
||||
+ Job.ID.getPreferredName() + "}/{" + ModelSnapshot.SNAPSHOT_ID +"}/description",
|
||||
controller.registerHandler(RestRequest.Method.PUT, PrelertPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/modelsnapshots/{" + ModelSnapshot.SNAPSHOT_ID +"}/description",
|
||||
this);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class RestRevertModelSnapshotAction extends BaseRestHandler {
|
|||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
PrelertPlugin.BASE_PATH + "modelsnapshots/{" + Job.ID.getPreferredName() + "}/_revert",
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/modelsnapshots/_revert",
|
||||
this);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,16 +32,16 @@ public class RestGetBucketsAction extends BaseRestHandler {
|
|||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName()
|
||||
+ "}/buckets/{" + Bucket.TIMESTAMP.getPreferredName() + "}", this);
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName()
|
||||
+ "}/results/buckets/{" + Bucket.TIMESTAMP.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName()
|
||||
+ "}/buckets/{" + Bucket.TIMESTAMP.getPreferredName() + "}", this);
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName()
|
||||
+ "}/results/buckets/{" + Bucket.TIMESTAMP.getPreferredName() + "}", this);
|
||||
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/buckets", this);
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/buckets", this);
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/buckets", this);
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/buckets", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,16 +30,16 @@ public class RestGetCategoriesAction extends BaseRestHandler {
|
|||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/categorydefinitions/{"
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categorydefinitions/{"
|
||||
+ Request.CATEGORY_ID.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/categorydefinitions", this);
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categorydefinitions", this);
|
||||
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/categorydefinitions/{"
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categorydefinitions/{"
|
||||
+ Request.CATEGORY_ID.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/categorydefinitions", this);
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categorydefinitions", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,10 +32,10 @@ public class RestGetInfluencersAction extends BaseRestHandler {
|
|||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/influencers", this);
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/influencers", this);
|
||||
// endpoints that support body parameters must also accept POST
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/influencers", this);
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/influencers", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,10 +31,10 @@ public class RestGetRecordsAction extends BaseRestHandler {
|
|||
public RestGetRecordsAction(Settings settings, RestController controller, GetRecordsAction.TransportAction transportAction) {
|
||||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(
|
||||
RestRequest.Method.GET, PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/records", this);
|
||||
controller.registerHandler(
|
||||
RestRequest.Method.POST, PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/records", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, PrelertPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/results/records", this);
|
||||
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/results/records", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,7 +52,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
|
||||
public void testGetJob_GivenNoSuchJob() throws Exception {
|
||||
ResponseException e = expectThrows(ResponseException.class,
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/non-existing-job/_stats"));
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/non-existing-job/_stats"));
|
||||
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
|
||||
assertThat(e.getMessage(), containsString("Could not find requested jobs"));
|
||||
|
@ -61,7 +61,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
public void testGetJob_GivenJobExists() throws Exception {
|
||||
createFarequoteJob();
|
||||
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/farequote/_stats");
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/farequote/_stats");
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
|
@ -71,7 +71,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
|
||||
public void testGetJobs_GivenNegativeFrom() throws Exception {
|
||||
ResponseException e = expectThrows(ResponseException.class,
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/_stats?from=-1"));
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/_stats?from=-1"));
|
||||
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(400));
|
||||
assertThat(e.getMessage(), containsString("\"reason\":\"Parameter [from] cannot be < 0\""));
|
||||
|
@ -79,7 +79,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
|
||||
public void testGetJobs_GivenNegativeSize() throws Exception {
|
||||
ResponseException e = expectThrows(ResponseException.class,
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/_stats?size=-1"));
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/_stats?size=-1"));
|
||||
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(400));
|
||||
assertThat(e.getMessage(), containsString("\"reason\":\"Parameter [size] cannot be < 0\""));
|
||||
|
@ -87,7 +87,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
|
||||
public void testGetJobs_GivenFromAndSizeSumTo10001() throws Exception {
|
||||
ResponseException e = expectThrows(ResponseException.class,
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/_stats?from=1000&size=11001"));
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/_stats?from=1000&size=11001"));
|
||||
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(400));
|
||||
assertThat(e.getMessage(), containsString("\"reason\":\"The sum of parameters [from] and [size] cannot be higher than 10000."));
|
||||
|
@ -96,7 +96,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
public void testGetJobs_GivenSingleJob() throws Exception {
|
||||
createFarequoteJob();
|
||||
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/_stats");
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/_stats");
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
|
@ -109,7 +109,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
createFarequoteJob("farequote_2");
|
||||
createFarequoteJob("farequote_3");
|
||||
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/_stats");
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/_stats");
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
|
@ -124,7 +124,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
createFarequoteJob("farequote_2");
|
||||
createFarequoteJob("farequote_3");
|
||||
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/_stats?from=1");
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/_stats?from=1");
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
|
@ -139,7 +139,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
createFarequoteJob("farequote_2");
|
||||
createFarequoteJob("farequote_3");
|
||||
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/_stats?size=1");
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/_stats?size=1");
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
|
@ -154,7 +154,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
createFarequoteJob("farequote_2");
|
||||
createFarequoteJob("farequote_3");
|
||||
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/_stats?from=1&size=1");
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/_stats?from=1&size=1");
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
|
@ -176,7 +176,7 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
"\"time_field\":\"time\",\n"
|
||||
+ " \"time_format\":\"yyyy-MM-dd HH:mm:ssX\"\n" + " }\n" + "}";
|
||||
|
||||
return client().performRequest("put", PrelertPlugin.BASE_PATH + "jobs", Collections.emptyMap(), new StringEntity(job));
|
||||
return client().performRequest("put", PrelertPlugin.BASE_PATH + "anomaly_detectors", Collections.emptyMap(), new StringEntity(job));
|
||||
}
|
||||
|
||||
public void testGetBucketResults() throws Exception {
|
||||
|
@ -185,32 +185,34 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
params.put("end", "1400"); // exclusive
|
||||
|
||||
ResponseException e = expectThrows(ResponseException.class,
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/buckets", params));
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/1/results/buckets", params));
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
|
||||
assertThat(e.getMessage(), containsString("No known job with id '1'"));
|
||||
|
||||
addBucketResult("1", "1234", 1);
|
||||
addBucketResult("1", "1235", 1);
|
||||
addBucketResult("1", "1236", 1);
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/buckets", params);
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/1/results/buckets", params);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"count\":3"));
|
||||
|
||||
params.put("end", "1235");
|
||||
response = client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/buckets", params);
|
||||
response = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/1/results/buckets", params);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"count\":1"));
|
||||
|
||||
e = expectThrows(ResponseException.class, () -> client().performRequest("get", PrelertPlugin.BASE_PATH + "results/2/buckets/1234"));
|
||||
e = expectThrows(ResponseException.class, () -> client().performRequest("get", PrelertPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/2/results/buckets/1234"));
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
|
||||
assertThat(e.getMessage(), containsString("No known job with id '2'"));
|
||||
|
||||
e = expectThrows(ResponseException.class, () -> client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/buckets/1"));
|
||||
e = expectThrows(ResponseException.class, () -> client().performRequest("get",
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/1/results/buckets/1"));
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
|
||||
|
||||
response = client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/buckets/1234");
|
||||
response = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/1/results/buckets/1234");
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, not(isEmptyString()));
|
||||
|
@ -222,20 +224,20 @@ public class PrelertJobIT extends ESRestTestCase {
|
|||
params.put("end", "1400"); // exclusive
|
||||
|
||||
ResponseException e = expectThrows(ResponseException.class,
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/records", params));
|
||||
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/1/results/records", params));
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
|
||||
assertThat(e.getMessage(), containsString("No known job with id '1'"));
|
||||
|
||||
addRecordResult("1", "1234", 1, 1);
|
||||
addRecordResult("1", "1235", 1, 2);
|
||||
addRecordResult("1", "1236", 1, 3);
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/records", params);
|
||||
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/1/results/records", params);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"count\":3"));
|
||||
|
||||
params.put("end", "1235");
|
||||
response = client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/records", params);
|
||||
response = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/1/results/records", params);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"count\":1"));
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ScheduledJobIT extends ESRestTestCase {
|
|||
assertThat(responseEntityToString(startSchedulerRequest), containsString("{\"task\":\""));
|
||||
assertBusy(() -> {
|
||||
try {
|
||||
Response getJobResponse = client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/" + jobId + "/_stats",
|
||||
Response getJobResponse = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats",
|
||||
Collections.singletonMap("metric", "data_counts"));
|
||||
assertThat(responseEntityToString(getJobResponse), containsString("\"input_record_count\":2"));
|
||||
} catch (Exception e) {
|
||||
|
@ -111,7 +111,7 @@ public class ScheduledJobIT extends ESRestTestCase {
|
|||
assertThat(responseEntityToString(response), containsString("{\"task\":\""));
|
||||
assertBusy(() -> {
|
||||
try {
|
||||
Response getJobResponse = client().performRequest("get", PrelertPlugin.BASE_PATH + "jobs/" + jobId + "/_stats",
|
||||
Response getJobResponse = client().performRequest("get", PrelertPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats",
|
||||
Collections.singletonMap("metric", "data_counts,status"));
|
||||
String responseAsString = responseEntityToString(getJobResponse);
|
||||
assertThat(responseAsString, containsString("\"status\":\"OPENED\""));
|
||||
|
@ -122,7 +122,7 @@ public class ScheduledJobIT extends ESRestTestCase {
|
|||
});
|
||||
|
||||
ResponseException e = expectThrows(ResponseException.class,
|
||||
() -> client().performRequest("delete", PrelertPlugin.BASE_PATH + "jobs/" + jobId));
|
||||
() -> client().performRequest("delete", PrelertPlugin.BASE_PATH + "anomaly_detectors/" + jobId));
|
||||
response = e.getResponse();
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(409));
|
||||
assertThat(responseEntityToString(response), containsString("Cannot delete job '" + jobId + "' while it is OPENED"));
|
||||
|
@ -132,8 +132,8 @@ public class ScheduledJobIT extends ESRestTestCase {
|
|||
assertThat(responseEntityToString(response), equalTo("{\"acknowledged\":true}"));
|
||||
waitForSchedulerStoppedState(client(), jobId);
|
||||
|
||||
client().performRequest("POST", "/_xpack/prelert/jobs/" + jobId + "/_close");
|
||||
response = client().performRequest("delete", PrelertPlugin.BASE_PATH + "jobs/" + jobId);
|
||||
client().performRequest("POST", "/_xpack/prelert/anomaly_detectors/" + jobId + "/_close");
|
||||
response = client().performRequest("delete", PrelertPlugin.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
assertThat(responseEntityToString(response), equalTo("{\"acknowledged\":true}"));
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public class ScheduledJobIT extends ESRestTestCase {
|
|||
"\"time_field\":\"time\",\n"
|
||||
+ " \"time_format\":\"yyyy-MM-dd'T'HH:mm:ssX\"\n" + " }\n" + "}";
|
||||
|
||||
return client().performRequest("put", PrelertPlugin.BASE_PATH + "jobs", Collections.emptyMap(), new StringEntity(job));
|
||||
return client().performRequest("put", PrelertPlugin.BASE_PATH + "anomaly_detectors", Collections.emptyMap(), new StringEntity(job));
|
||||
}
|
||||
|
||||
private Response createScheduledJob(String id) throws Exception {
|
||||
|
@ -174,7 +174,7 @@ public class ScheduledJobIT extends ESRestTestCase {
|
|||
+ " \"scheduler_config\" : {\n" + " \"indexes\":[\"airline-data\"],\n"
|
||||
+ " \"types\":[\"response\"],\n" + " \"retrieve_whole_source\":true\n" + " }\n" + "}";
|
||||
|
||||
return client().performRequest("put", PrelertPlugin.BASE_PATH + "jobs", Collections.emptyMap(), new StringEntity(job));
|
||||
return client().performRequest("put", PrelertPlugin.BASE_PATH + "anomaly_detectors", Collections.emptyMap(), new StringEntity(job));
|
||||
}
|
||||
|
||||
private static String responseEntityToString(Response response) throws Exception {
|
||||
|
@ -187,7 +187,8 @@ public class ScheduledJobIT extends ESRestTestCase {
|
|||
try {
|
||||
assertBusy(() -> {
|
||||
try {
|
||||
Response getJobResponse = client.performRequest("get", PrelertPlugin.BASE_PATH + "jobs/" + jobId + "/_stats",
|
||||
Response getJobResponse = client.performRequest("get",
|
||||
PrelertPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats",
|
||||
Collections.singletonMap("metric", "scheduler_status"));
|
||||
assertThat(responseEntityToString(getJobResponse), containsString("\"status\":\"STOPPED\""));
|
||||
} catch (Exception e) {
|
||||
|
@ -225,17 +226,17 @@ public class ScheduledJobIT extends ESRestTestCase {
|
|||
// ignore
|
||||
}
|
||||
try {
|
||||
Response response = client.performRequest("POST", "/_xpack/prelert/jobs/" + jobId + "/_close");
|
||||
Response response = client.performRequest("POST", "/_xpack/prelert/anomaly_detectors/" + jobId + "/_close");
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
client.performRequest("DELETE", "/_xpack/prelert/jobs/" + jobId);
|
||||
client.performRequest("DELETE", "/_xpack/prelert/anomaly_detectors/" + jobId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void openJob(RestClient client, String jobId) throws IOException {
|
||||
Response response = client.performRequest("post", PrelertPlugin.BASE_PATH + "jobs/" + jobId + "/_open");
|
||||
Response response = client.performRequest("post", PrelertPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_open");
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"xpack.prelert.close_job": {
|
||||
"methods": [ "POST" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/jobs/{job_id}/_close",
|
||||
"paths": [ "/_xpack/prelert/jobs/{job_id}/_close" ],
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/_close",
|
||||
"paths": [ "/_xpack/prelert/anomaly_detectors/{job_id}/_close" ],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
"type": "string",
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"xpack.prelert.delete_job": {
|
||||
"methods": [ "DELETE" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/jobs/{job_id}",
|
||||
"paths": [ "/_xpack/prelert/jobs/{job_id}" ],
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}",
|
||||
"paths": [ "/_xpack/prelert/anomaly_detectors/{job_id}" ],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
"type": "string",
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"xpack.prelert.delete_model_snapshot": {
|
||||
"methods": [ "DELETE" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/modelsnapshots/{job_id}/{snapshot_id}",
|
||||
"paths": [ "/_xpack/prelert/modelsnapshots/{job_id}/{snapshot_id}" ],
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/modelsnapshots/{snapshot_id}",
|
||||
"paths": [ "/_xpack/prelert/anomaly_detectors/{job_id}/modelsnapshots/{snapshot_id}" ],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
"type": "string",
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
"POST"
|
||||
],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/jobs/{job_id}/_flush",
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/_flush",
|
||||
"paths": [
|
||||
"/_xpack/prelert/jobs/{job_id}/_flush"
|
||||
"/_xpack/prelert/anomaly_detectors/{job_id}/_flush"
|
||||
],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
"xpack.prelert.get_buckets": {
|
||||
"methods": [ "GET", "POST" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/results/{job_id}/buckets/{timestamp}",
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/results/buckets/{timestamp}",
|
||||
"paths": [
|
||||
"/_xpack/prelert/results/{job_id}/buckets/{timestamp}",
|
||||
"/_xpack/prelert/results/{job_id}/buckets"
|
||||
"/_xpack/prelert/anomaly_detectors/{job_id}/results/buckets/{timestamp}",
|
||||
"/_xpack/prelert/anomaly_detectors/{job_id}/results/buckets"
|
||||
],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
"xpack.prelert.get_categories": {
|
||||
"methods": [ "GET", "POST" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/results/{job_id}/categorydefinitions/{category_id}",
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/results/categorydefinitions/{category_id}",
|
||||
"paths": [
|
||||
"/_xpack/prelert/results/{job_id}/categorydefinitions/{category_id}",
|
||||
"/_xpack/prelert/results/{job_id}/categorydefinitions/"
|
||||
"/_xpack/prelert/anomaly_detectors/{job_id}/results/categorydefinitions/{category_id}",
|
||||
"/_xpack/prelert/anomaly_detectors/{job_id}/results/categorydefinitions/"
|
||||
],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"xpack.prelert.get_influencers": {
|
||||
"methods": [ "GET", "POST" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/results/{job_id}/influencers",
|
||||
"paths": [ "/_xpack/prelert/results/{job_id}/influencers" ],
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/results/influencers",
|
||||
"paths": [ "/_xpack/prelert/anomaly_detectors/{job_id}/results/influencers" ],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
"type" : "string",
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"xpack.prelert.get_jobs": {
|
||||
"methods": [ "GET", "POST" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/jobs/{job_id}",
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}",
|
||||
"paths": [
|
||||
"/_xpack/prelert/jobs/_stats",
|
||||
"/_xpack/prelert/jobs/{job_id}/_stats",
|
||||
"/_xpack/prelert/jobs/{job_id}/_stats/{metric}"
|
||||
"/_xpack/prelert/anomaly_detectors/_stats",
|
||||
"/_xpack/prelert/anomaly_detectors/{job_id}/_stats",
|
||||
"/_xpack/prelert/anomaly_detectors/{job_id}/_stats/{metric}"
|
||||
],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"xpack.prelert.get_model_snapshots": {
|
||||
"methods": [ "GET", "POST" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/modelsnapshots/{job_id}",
|
||||
"paths": [ "/_xpack/prelert/modelsnapshots/{job_id}" ],
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/modelsnapshots",
|
||||
"paths": [ "/_xpack/prelert/anomaly_detectors/{job_id}/modelsnapshots" ],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
"type": "string",
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
"xpack.prelert.get_records": {
|
||||
"methods": ["GET", "POST"],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/results/{job_id}/records",
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/results/records",
|
||||
"paths": [
|
||||
"/_xpack/prelert/results/{job_id}/records"
|
||||
"/_xpack/prelert/anomaly_detectors/{job_id}/results/records"
|
||||
],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"xpack.prelert.job_data": {
|
||||
"methods": [ "POST" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/jobs/{job_id}/data",
|
||||
"paths": [ "/_xpack/prelert/jobs/{job_id}/data" ],
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/data",
|
||||
"paths": [ "/_xpack/prelert/anomaly_detectors/{job_id}/data" ],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
"type": "string",
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"xpack.prelert.open_job": {
|
||||
"methods": [ "POST" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/jobs/{job_id}/_open",
|
||||
"paths": [ "/_xpack/prelert/jobs/{job_id}/_open" ],
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/_open",
|
||||
"paths": [ "/_xpack/prelert/anomaly_detectors/{job_id}/_open" ],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
"type": "string",
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"xpack.prelert.put_job": {
|
||||
"methods": [ "PUT" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/jobs",
|
||||
"paths": [ "/_xpack/prelert/jobs" ],
|
||||
"path": "/_xpack/prelert/anomaly_detectors",
|
||||
"paths": [ "/_xpack/prelert/anomaly_detectors" ],
|
||||
"params": {
|
||||
"overwrite": {
|
||||
"type": "boolean",
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"xpack.prelert.put_model_snapshot_description": {
|
||||
"methods": [ "PUT" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/modelsnapshots/{job_id}/{snapshot_id}/description",
|
||||
"paths": [ "/_xpack/prelert/modelsnapshots/{job_id}/{snapshot_id}/description" ],
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/modelsnapshots/{snapshot_id}/description",
|
||||
"paths": [ "/_xpack/prelert/anomaly_detectors/{job_id}/modelsnapshots/{snapshot_id}/description" ],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
"type": "string",
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"xpack.prelert.revert_model_snapshot": {
|
||||
"methods": [ "POST" ],
|
||||
"url": {
|
||||
"path": "/_xpack/prelert/modelsnapshots/{job_id}/_revert",
|
||||
"paths": [ "/_xpack/prelert/modelsnapshots/{job_id}/_revert" ],
|
||||
"path": "/_xpack/prelert/anomaly_detectors/{job_id}/modelsnapshots/_revert",
|
||||
"paths": [ "/_xpack/prelert/anomaly_detectors/{job_id}/modelsnapshots/_revert" ],
|
||||
"parts": {
|
||||
"job_id": {
|
||||
"type": "string",
|
||||
|
|
Loading…
Reference in New Issue