mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
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
This commit is contained in:
parent
433a506d06
commit
f8f521bad4
x-pack/plugin
core/src/main/java/org/elasticsearch/xpack/core/monitoring/exporter
monitoring/src
main/java/org/elasticsearch/xpack/monitoring/rest
test/java/org/elasticsearch/xpack/monitoring
cleaner
exporter/local
integration
rest/action
src/test/resources/rest-api-spec
@ -35,7 +35,7 @@ public final class MonitoringTemplateUtils {
|
|||||||
*/
|
*/
|
||||||
public static final String TEMPLATE_VERSION = "6";
|
public static final String TEMPLATE_VERSION = "6";
|
||||||
/**
|
/**
|
||||||
* The previous version of templates, which we still support via the REST _xpack/monitoring/_bulk endpoint because
|
* The previous version of templates, which we still support via the REST /_monitoring/bulk endpoint because
|
||||||
* nothing changed for those documents.
|
* nothing changed for those documents.
|
||||||
*/
|
*/
|
||||||
public static final String OLD_TEMPLATE_VERSION = "2";
|
public static final String OLD_TEMPLATE_VERSION = "2";
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* 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.monitoring.rest;
|
|
||||||
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
|
||||||
import org.elasticsearch.xpack.core.rest.XPackRestHandler;
|
|
||||||
|
|
||||||
public abstract class MonitoringRestHandler extends XPackRestHandler {
|
|
||||||
|
|
||||||
protected static String URI_BASE = XPackRestHandler.URI_BASE + "/monitoring";
|
|
||||||
|
|
||||||
public MonitoringRestHandler(Settings settings) {
|
|
||||||
super(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -5,8 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.monitoring.rest.action;
|
package org.elasticsearch.xpack.monitoring.rest.action;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
|
import org.elasticsearch.common.logging.DeprecationLogger;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.rest.BytesRestResponse;
|
import org.elasticsearch.rest.BytesRestResponse;
|
||||||
@ -19,7 +21,7 @@ import org.elasticsearch.xpack.core.monitoring.MonitoredSystem;
|
|||||||
import org.elasticsearch.xpack.core.monitoring.action.MonitoringBulkRequestBuilder;
|
import org.elasticsearch.xpack.core.monitoring.action.MonitoringBulkRequestBuilder;
|
||||||
import org.elasticsearch.xpack.core.monitoring.action.MonitoringBulkResponse;
|
import org.elasticsearch.xpack.core.monitoring.action.MonitoringBulkResponse;
|
||||||
import org.elasticsearch.xpack.core.monitoring.exporter.MonitoringTemplateUtils;
|
import org.elasticsearch.xpack.core.monitoring.exporter.MonitoringTemplateUtils;
|
||||||
import org.elasticsearch.xpack.monitoring.rest.MonitoringRestHandler;
|
import org.elasticsearch.xpack.core.rest.XPackRestHandler;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -33,20 +35,25 @@ import static org.elasticsearch.common.unit.TimeValue.parseTimeValue;
|
|||||||
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.PUT;
|
import static org.elasticsearch.rest.RestRequest.Method.PUT;
|
||||||
|
|
||||||
public class RestMonitoringBulkAction extends MonitoringRestHandler {
|
public class RestMonitoringBulkAction extends XPackRestHandler {
|
||||||
|
|
||||||
public static final String MONITORING_ID = "system_id";
|
public static final String MONITORING_ID = "system_id";
|
||||||
public static final String MONITORING_VERSION = "system_api_version";
|
public static final String MONITORING_VERSION = "system_api_version";
|
||||||
public static final String INTERVAL = "interval";
|
public static final String INTERVAL = "interval";
|
||||||
|
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestMonitoringBulkAction.class));
|
||||||
private final Map<MonitoredSystem, List<String>> supportedApiVersions;
|
private final Map<MonitoredSystem, List<String>> supportedApiVersions;
|
||||||
|
|
||||||
public RestMonitoringBulkAction(Settings settings, RestController controller) {
|
public RestMonitoringBulkAction(Settings settings, RestController controller) {
|
||||||
super(settings);
|
super(settings);
|
||||||
controller.registerHandler(POST, URI_BASE + "/_bulk", this);
|
// TODO: remove deprecated endpoint in 8.0.0
|
||||||
controller.registerHandler(PUT, URI_BASE + "/_bulk", this);
|
controller.registerWithDeprecatedHandler(POST, "/_monitoring/bulk", this,
|
||||||
controller.registerHandler(POST, URI_BASE + "/{type}/_bulk", this);
|
POST, "/_xpack/monitoring/_bulk", deprecationLogger);
|
||||||
controller.registerHandler(PUT, URI_BASE + "/{type}/_bulk", this);
|
controller.registerWithDeprecatedHandler(PUT, "/_monitoring/bulk", this,
|
||||||
|
PUT, "/_xpack/monitoring/_bulk", deprecationLogger);
|
||||||
|
controller.registerWithDeprecatedHandler(POST, "/_monitoring/{type}/bulk", this,
|
||||||
|
POST, "/_xpack/monitoring/{type}/_bulk", deprecationLogger);
|
||||||
|
controller.registerWithDeprecatedHandler(PUT, "/_monitoring/{type}/bulk", this,
|
||||||
|
PUT, "/_xpack/monitoring/{type}/_bulk", deprecationLogger);
|
||||||
|
|
||||||
final List<String> allVersions = Arrays.asList(
|
final List<String> allVersions = Arrays.asList(
|
||||||
MonitoringTemplateUtils.TEMPLATE_VERSION,
|
MonitoringTemplateUtils.TEMPLATE_VERSION,
|
||||||
@ -63,7 +70,7 @@ public class RestMonitoringBulkAction extends MonitoringRestHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "xpack_monitoring_bulk_action";
|
return "monitoring_bulk";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,8 +74,7 @@ public abstract class AbstractIndicesCleanerTestCase extends MonitoringIntegTest
|
|||||||
createTimestampedIndex(now().minusYears(1), MonitoringTemplateUtils.OLD_TEMPLATE_VERSION);
|
createTimestampedIndex(now().minusYears(1), MonitoringTemplateUtils.OLD_TEMPLATE_VERSION);
|
||||||
// In the past, this index would not be deleted, but starting in 6.x the monitoring cluster
|
// In the past, this index would not be deleted, but starting in 6.x the monitoring cluster
|
||||||
// will be required to be a newer template version than the production cluster, so the index
|
// will be required to be a newer template version than the production cluster, so the index
|
||||||
// pushed to it will never be "unknown" in terms of their version (relates to the
|
// pushed to it will never be "unknown" in terms of their version
|
||||||
// _xpack/monitoring/_setup API)
|
|
||||||
createTimestampedIndex(now().minusDays(10), String.valueOf(Integer.MAX_VALUE));
|
createTimestampedIndex(now().minusDays(10), String.valueOf(Integer.MAX_VALUE));
|
||||||
|
|
||||||
// Won't be deleted
|
// Won't be deleted
|
||||||
|
@ -84,7 +84,7 @@ public class LocalExporterIntegTests extends LocalExporterIntegTestCase {
|
|||||||
indexRandom(true, indexRequestBuilders);
|
indexRandom(true, indexRequestBuilders);
|
||||||
}
|
}
|
||||||
|
|
||||||
// start the monitoring service so that _xpack/monitoring/_bulk is not ignored
|
// start the monitoring service so that /_monitoring/bulk is not ignored
|
||||||
final Settings.Builder exporterSettings = Settings.builder()
|
final Settings.Builder exporterSettings = Settings.builder()
|
||||||
.put(MonitoringService.ENABLED.getKey(), true)
|
.put(MonitoringService.ENABLED.getKey(), true)
|
||||||
.put("xpack.monitoring.exporters._local.enabled", true)
|
.put("xpack.monitoring.exporters._local.enabled", true)
|
||||||
|
@ -113,23 +113,17 @@ public class MonitoringIT extends ESSingleNodeTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitoring Bulk API test:
|
* Monitoring Bulk test:
|
||||||
*
|
*
|
||||||
* This test uses the Monitoring Bulk API to index document as an external application like Kibana would do. It
|
* This test uses the Monitoring Bulk Request to index documents. It then ensure that the documents were correctly
|
||||||
* then ensure that the documents were correctly indexed and have the expected information.
|
* indexed and have the expected information. REST API tests (like how this is really called) are handled as part of the
|
||||||
|
* XPackRest tests.
|
||||||
*/
|
*/
|
||||||
public void testMonitoringBulk() throws Exception {
|
public void testMonitoringBulk() throws Exception {
|
||||||
whenExportersAreReady(() -> {
|
whenExportersAreReady(() -> {
|
||||||
final MonitoredSystem system = randomSystem();
|
final MonitoredSystem system = randomSystem();
|
||||||
final TimeValue interval = TimeValue.timeValueSeconds(randomIntBetween(1, 20));
|
final TimeValue interval = TimeValue.timeValueSeconds(randomIntBetween(1, 20));
|
||||||
|
|
||||||
// REST is the realistic way that these operations happen, so it's the most realistic way to integration test it too
|
|
||||||
// Use Monitoring Bulk API to index 3 documents
|
|
||||||
//final Request bulkRequest = new Request("POST", "/_xpack/monitoring/_bulk");
|
|
||||||
//<<add all parameters>
|
|
||||||
//bulkRequest.setJsonEntity(createBulkEntity());
|
|
||||||
//final Response bulkResponse = getRestClient().performRequest(request);
|
|
||||||
|
|
||||||
final MonitoringBulkResponse bulkResponse =
|
final MonitoringBulkResponse bulkResponse =
|
||||||
new MonitoringBulkRequestBuilder(client())
|
new MonitoringBulkRequestBuilder(client())
|
||||||
.add(system, null, new BytesArray(createBulkEntity().getBytes("UTF-8")), XContentType.JSON,
|
.add(system, null, new BytesArray(createBulkEntity().getBytes("UTF-8")), XContentType.JSON,
|
||||||
|
@ -52,7 +52,7 @@ public class RestMonitoringBulkActionTests extends ESTestCase {
|
|||||||
|
|
||||||
public void testGetName() {
|
public void testGetName() {
|
||||||
// Are you sure that you want to change the name?
|
// Are you sure that you want to change the name?
|
||||||
assertThat(action.getName(), is("xpack_monitoring_bulk_action"));
|
assertThat(action.getName(), is("monitoring_bulk"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSupportsContentStream() {
|
public void testSupportsContentStream() {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"xpack.monitoring.bulk": {
|
"monitoring.bulk": {
|
||||||
"documentation": "http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html",
|
"documentation": "http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html",
|
||||||
"methods": ["POST", "PUT"],
|
"methods": ["POST", "PUT"],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_xpack/monitoring/_bulk",
|
"path": "/_monitoring/bulk",
|
||||||
"paths": ["/_xpack/monitoring/_bulk", "/_xpack/monitoring/{type}/_bulk"],
|
"paths": ["/_monitoring/bulk", "/_monitoring/{type}/bulk"],
|
||||||
"parts": {
|
"parts": {
|
||||||
"type": {
|
"type": {
|
||||||
"type" : "string",
|
"type" : "string",
|
@ -2,7 +2,7 @@
|
|||||||
"Bulk indexing of monitoring data":
|
"Bulk indexing of monitoring data":
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
xpack.monitoring.bulk:
|
monitoring.bulk:
|
||||||
system_id: "kibana"
|
system_id: "kibana"
|
||||||
system_api_version: "6"
|
system_api_version: "6"
|
||||||
interval: "10s"
|
interval: "10s"
|
||||||
@ -37,7 +37,7 @@
|
|||||||
- match: { hits.total: 2 }
|
- match: { hits.total: 2 }
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
xpack.monitoring.bulk:
|
monitoring.bulk:
|
||||||
system_id: "kibana"
|
system_id: "kibana"
|
||||||
system_api_version: "6"
|
system_api_version: "6"
|
||||||
interval: "123456ms"
|
interval: "123456ms"
|
||||||
@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
# Old system_api_version should still be accepted
|
# Old system_api_version should still be accepted
|
||||||
- do:
|
- do:
|
||||||
xpack.monitoring.bulk:
|
monitoring.bulk:
|
||||||
system_id: "kibana"
|
system_id: "kibana"
|
||||||
system_api_version: "2"
|
system_api_version: "2"
|
||||||
interval: "10000ms"
|
interval: "10000ms"
|
||||||
@ -127,7 +127,7 @@
|
|||||||
# Missing a system_id causes it to fail
|
# Missing a system_id causes it to fail
|
||||||
- do:
|
- do:
|
||||||
catch: bad_request
|
catch: bad_request
|
||||||
xpack.monitoring.bulk:
|
monitoring.bulk:
|
||||||
system_api_version: "6"
|
system_api_version: "6"
|
||||||
interval: "10s"
|
interval: "10s"
|
||||||
type: "default_type"
|
type: "default_type"
|
||||||
@ -138,7 +138,7 @@
|
|||||||
# Missing a system_api_version causes it to fail
|
# Missing a system_api_version causes it to fail
|
||||||
- do:
|
- do:
|
||||||
catch: bad_request
|
catch: bad_request
|
||||||
xpack.monitoring.bulk:
|
monitoring.bulk:
|
||||||
system_id: "kibana"
|
system_id: "kibana"
|
||||||
interval: "10s"
|
interval: "10s"
|
||||||
type: "default_type"
|
type: "default_type"
|
||||||
@ -149,7 +149,7 @@
|
|||||||
# Missing an interval causes it to fail
|
# Missing an interval causes it to fail
|
||||||
- do:
|
- do:
|
||||||
catch: bad_request
|
catch: bad_request
|
||||||
xpack.monitoring.bulk:
|
monitoring.bulk:
|
||||||
system_id: "kibana"
|
system_id: "kibana"
|
||||||
system_api_version: "6"
|
system_api_version: "6"
|
||||||
type: "default_type"
|
type: "default_type"
|
||||||
@ -161,7 +161,7 @@
|
|||||||
"Bulk indexing of monitoring data on closed indices should throw an export exception":
|
"Bulk indexing of monitoring data on closed indices should throw an export exception":
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
xpack.monitoring.bulk:
|
monitoring.bulk:
|
||||||
system_id: "beats"
|
system_id: "beats"
|
||||||
system_api_version: "6"
|
system_api_version: "6"
|
||||||
interval: "5s"
|
interval: "5s"
|
||||||
@ -193,7 +193,7 @@
|
|||||||
|
|
||||||
- do:
|
- do:
|
||||||
catch: /export_exception/
|
catch: /export_exception/
|
||||||
xpack.monitoring.bulk:
|
monitoring.bulk:
|
||||||
system_id: "beats"
|
system_id: "beats"
|
||||||
system_api_version: "6"
|
system_api_version: "6"
|
||||||
interval: "5s"
|
interval: "5s"
|
||||||
|
@ -82,7 +82,7 @@ teardown:
|
|||||||
headers:
|
headers:
|
||||||
# Authorization: logstash_agent
|
# Authorization: logstash_agent
|
||||||
Authorization: "Basic bG9nc3Rhc2hfYWdlbnQ6czNrcml0"
|
Authorization: "Basic bG9nc3Rhc2hfYWdlbnQ6czNrcml0"
|
||||||
xpack.monitoring.bulk:
|
monitoring.bulk:
|
||||||
system_id: "logstash"
|
system_id: "logstash"
|
||||||
system_api_version: "6"
|
system_api_version: "6"
|
||||||
interval: "10s"
|
interval: "10s"
|
||||||
@ -118,7 +118,7 @@ teardown:
|
|||||||
headers:
|
headers:
|
||||||
# Authorization: unknown_agent
|
# Authorization: unknown_agent
|
||||||
Authorization: "Basic dW5rbm93bl9hZ2VudDpzM2tyaXQ="
|
Authorization: "Basic dW5rbm93bl9hZ2VudDpzM2tyaXQ="
|
||||||
xpack.monitoring.bulk:
|
monitoring.bulk:
|
||||||
system_id: "logstash"
|
system_id: "logstash"
|
||||||
system_api_version: "6"
|
system_api_version: "6"
|
||||||
interval: "10s"
|
interval: "10s"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user