Skip to content

Commit 34fc485

Browse files
jakelandisspinscale
authored andcommitted
Deprecate /_xpack/monitoring/* in favor of /_monitoring/* (#36130)
This commit is part of our plan to deprecate and ultimately remove the use of _xpack in the REST APIs. * Add deprecation for /_xpack/monitoring/_bulk in favor of /_monitoring/bulk * Removed xpack from the rest-api-spec and tests * Removed xpack from the Action name * Removed MonitoringRestHandler as an unnecessary abstraction * Minor corrections to comments Relates #35958
1 parent f486f63 commit 34fc485

File tree

10 files changed

+36
-55
lines changed

10 files changed

+36
-55
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/exporter/MonitoringTemplateUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public final class MonitoringTemplateUtils {
3535
*/
3636
public static final String TEMPLATE_VERSION = "6";
3737
/**
38-
* The previous version of templates, which we still support via the REST _xpack/monitoring/_bulk endpoint because
38+
* The previous version of templates, which we still support via the REST /_monitoring/bulk endpoint because
3939
* nothing changed for those documents.
4040
*/
4141
public static final String OLD_TEMPLATE_VERSION = "2";

x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/rest/MonitoringRestHandler.java

-19
This file was deleted.

x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java

+15-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
*/
66
package org.elasticsearch.xpack.monitoring.rest.action;
77

8+
import org.apache.logging.log4j.LogManager;
89
import org.elasticsearch.ElasticsearchParseException;
910
import org.elasticsearch.common.Strings;
11+
import org.elasticsearch.common.logging.DeprecationLogger;
1012
import org.elasticsearch.common.settings.Settings;
1113
import org.elasticsearch.common.xcontent.XContentBuilder;
1214
import org.elasticsearch.rest.BytesRestResponse;
@@ -19,7 +21,7 @@
1921
import org.elasticsearch.xpack.core.monitoring.action.MonitoringBulkRequestBuilder;
2022
import org.elasticsearch.xpack.core.monitoring.action.MonitoringBulkResponse;
2123
import org.elasticsearch.xpack.core.monitoring.exporter.MonitoringTemplateUtils;
22-
import org.elasticsearch.xpack.monitoring.rest.MonitoringRestHandler;
24+
import org.elasticsearch.xpack.core.rest.XPackRestHandler;
2325

2426
import java.io.IOException;
2527
import java.util.Arrays;
@@ -33,20 +35,25 @@
3335
import static org.elasticsearch.rest.RestRequest.Method.POST;
3436
import static org.elasticsearch.rest.RestRequest.Method.PUT;
3537

36-
public class RestMonitoringBulkAction extends MonitoringRestHandler {
38+
public class RestMonitoringBulkAction extends XPackRestHandler {
3739

3840
public static final String MONITORING_ID = "system_id";
3941
public static final String MONITORING_VERSION = "system_api_version";
4042
public static final String INTERVAL = "interval";
41-
43+
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestMonitoringBulkAction.class));
4244
private final Map<MonitoredSystem, List<String>> supportedApiVersions;
4345

4446
public RestMonitoringBulkAction(Settings settings, RestController controller) {
4547
super(settings);
46-
controller.registerHandler(POST, URI_BASE + "/_bulk", this);
47-
controller.registerHandler(PUT, URI_BASE + "/_bulk", this);
48-
controller.registerHandler(POST, URI_BASE + "/{type}/_bulk", this);
49-
controller.registerHandler(PUT, URI_BASE + "/{type}/_bulk", this);
48+
// TODO: remove deprecated endpoint in 8.0.0
49+
controller.registerWithDeprecatedHandler(POST, "/_monitoring/bulk", this,
50+
POST, "/_xpack/monitoring/_bulk", deprecationLogger);
51+
controller.registerWithDeprecatedHandler(PUT, "/_monitoring/bulk", this,
52+
PUT, "/_xpack/monitoring/_bulk", deprecationLogger);
53+
controller.registerWithDeprecatedHandler(POST, "/_monitoring/{type}/bulk", this,
54+
POST, "/_xpack/monitoring/{type}/_bulk", deprecationLogger);
55+
controller.registerWithDeprecatedHandler(PUT, "/_monitoring/{type}/bulk", this,
56+
PUT, "/_xpack/monitoring/{type}/_bulk", deprecationLogger);
5057

5158
final List<String> allVersions = Arrays.asList(
5259
MonitoringTemplateUtils.TEMPLATE_VERSION,
@@ -63,7 +70,7 @@ public RestMonitoringBulkAction(Settings settings, RestController controller) {
6370

6471
@Override
6572
public String getName() {
66-
return "xpack_monitoring_bulk_action";
73+
return "monitoring_bulk";
6774
}
6875

6976
@Override

x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ public void testDoesNotIgnoreIndicesInOtherVersions() throws Exception {
7474
createTimestampedIndex(now().minusYears(1), MonitoringTemplateUtils.OLD_TEMPLATE_VERSION);
7575
// In the past, this index would not be deleted, but starting in 6.x the monitoring cluster
7676
// will be required to be a newer template version than the production cluster, so the index
77-
// pushed to it will never be "unknown" in terms of their version (relates to the
78-
// _xpack/monitoring/_setup API)
77+
// pushed to it will never be "unknown" in terms of their version
7978
createTimestampedIndex(now().minusDays(10), String.valueOf(Integer.MAX_VALUE));
8079

8180
// Won't be deleted

x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void testExport() throws Exception {
8484
indexRandom(true, indexRequestBuilders);
8585
}
8686

87-
// start the monitoring service so that _xpack/monitoring/_bulk is not ignored
87+
// start the monitoring service so that /_monitoring/bulk is not ignored
8888
final Settings.Builder exporterSettings = Settings.builder()
8989
.put(MonitoringService.ENABLED.getKey(), true)
9090
.put("xpack.monitoring.exporters._local.enabled", true)

x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,17 @@ private String createBulkEntity() {
113113
}
114114

115115
/**
116-
* Monitoring Bulk API test:
116+
* Monitoring Bulk test:
117117
*
118-
* This test uses the Monitoring Bulk API to index document as an external application like Kibana would do. It
119-
* then ensure that the documents were correctly indexed and have the expected information.
118+
* This test uses the Monitoring Bulk Request to index documents. It then ensure that the documents were correctly
119+
* indexed and have the expected information. REST API tests (like how this is really called) are handled as part of the
120+
* XPackRest tests.
120121
*/
121122
public void testMonitoringBulk() throws Exception {
122123
whenExportersAreReady(() -> {
123124
final MonitoredSystem system = randomSystem();
124125
final TimeValue interval = TimeValue.timeValueSeconds(randomIntBetween(1, 20));
125126

126-
// REST is the realistic way that these operations happen, so it's the most realistic way to integration test it too
127-
// Use Monitoring Bulk API to index 3 documents
128-
//final Request bulkRequest = new Request("POST", "/_xpack/monitoring/_bulk");
129-
//<<add all parameters>
130-
//bulkRequest.setJsonEntity(createBulkEntity());
131-
//final Response bulkResponse = getRestClient().performRequest(request);
132-
133127
final MonitoringBulkResponse bulkResponse =
134128
new MonitoringBulkRequestBuilder(client())
135129
.add(system, null, new BytesArray(createBulkEntity().getBytes("UTF-8")), XContentType.JSON,

x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class RestMonitoringBulkActionTests extends ESTestCase {
5252

5353
public void testGetName() {
5454
// Are you sure that you want to change the name?
55-
assertThat(action.getName(), is("xpack_monitoring_bulk_action"));
55+
assertThat(action.getName(), is("monitoring_bulk"));
5656
}
5757

5858
public void testSupportsContentStream() {

x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.monitoring.bulk.json renamed to x-pack/plugin/src/test/resources/rest-api-spec/api/monitoring.bulk.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"xpack.monitoring.bulk": {
2+
"monitoring.bulk": {
33
"documentation": "http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html",
44
"methods": ["POST", "PUT"],
55
"url": {
6-
"path": "/_xpack/monitoring/_bulk",
7-
"paths": ["/_xpack/monitoring/_bulk", "/_xpack/monitoring/{type}/_bulk"],
6+
"path": "/_monitoring/bulk",
7+
"paths": ["/_monitoring/bulk", "/_monitoring/{type}/bulk"],
88
"parts": {
99
"type": {
1010
"type" : "string",

x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"Bulk indexing of monitoring data":
33

44
- do:
5-
xpack.monitoring.bulk:
5+
monitoring.bulk:
66
system_id: "kibana"
77
system_api_version: "6"
88
interval: "10s"
@@ -37,7 +37,7 @@
3737
- match: { hits.total: 2 }
3838

3939
- do:
40-
xpack.monitoring.bulk:
40+
monitoring.bulk:
4141
system_id: "kibana"
4242
system_api_version: "6"
4343
interval: "123456ms"
@@ -83,7 +83,7 @@
8383

8484
# Old system_api_version should still be accepted
8585
- do:
86-
xpack.monitoring.bulk:
86+
monitoring.bulk:
8787
system_id: "kibana"
8888
system_api_version: "2"
8989
interval: "10000ms"
@@ -127,7 +127,7 @@
127127
# Missing a system_id causes it to fail
128128
- do:
129129
catch: bad_request
130-
xpack.monitoring.bulk:
130+
monitoring.bulk:
131131
system_api_version: "6"
132132
interval: "10s"
133133
type: "default_type"
@@ -138,7 +138,7 @@
138138
# Missing a system_api_version causes it to fail
139139
- do:
140140
catch: bad_request
141-
xpack.monitoring.bulk:
141+
monitoring.bulk:
142142
system_id: "kibana"
143143
interval: "10s"
144144
type: "default_type"
@@ -149,7 +149,7 @@
149149
# Missing an interval causes it to fail
150150
- do:
151151
catch: bad_request
152-
xpack.monitoring.bulk:
152+
monitoring.bulk:
153153
system_id: "kibana"
154154
system_api_version: "6"
155155
type: "default_type"
@@ -161,7 +161,7 @@
161161
"Bulk indexing of monitoring data on closed indices should throw an export exception":
162162

163163
- do:
164-
xpack.monitoring.bulk:
164+
monitoring.bulk:
165165
system_id: "beats"
166166
system_api_version: "6"
167167
interval: "5s"
@@ -193,7 +193,7 @@
193193

194194
- do:
195195
catch: /export_exception/
196-
xpack.monitoring.bulk:
196+
monitoring.bulk:
197197
system_id: "beats"
198198
system_api_version: "6"
199199
interval: "5s"

x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/20_privileges.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ teardown:
8282
headers:
8383
# Authorization: logstash_agent
8484
Authorization: "Basic bG9nc3Rhc2hfYWdlbnQ6czNrcml0"
85-
xpack.monitoring.bulk:
85+
monitoring.bulk:
8686
system_id: "logstash"
8787
system_api_version: "6"
8888
interval: "10s"
@@ -118,7 +118,7 @@ teardown:
118118
headers:
119119
# Authorization: unknown_agent
120120
Authorization: "Basic dW5rbm93bl9hZ2VudDpzM2tyaXQ="
121-
xpack.monitoring.bulk:
121+
monitoring.bulk:
122122
system_id: "logstash"
123123
system_api_version: "6"
124124
interval: "10s"

0 commit comments

Comments
 (0)