[Monitoring] Future-proof Monitoring Bulk API with "interval" param
This adds an "interval" placeholder parameter that is required to the Monitoring Bulk API, and adds it to the Kibana side of the plumbing. Having this will allow us to add it to all incoming documents and start to report against it with the Insights, as well as to detect the _lack_ of incoming documents. By adding it now, we can avoid having a non-BWC API change for Kibana in 5.1. We'll just pickup new data in our documents. Original commit: elastic/x-pack-elasticsearch@5ba8aafe03
This commit is contained in:
parent
2dde85ab33
commit
a94c27d3de
|
@ -6,7 +6,6 @@
|
|||
package org.elasticsearch.xpack.monitoring.rest.action;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -30,6 +29,7 @@ public class RestMonitoringBulkAction extends MonitoringRestHandler {
|
|||
|
||||
public static final String MONITORING_ID = "system_id";
|
||||
public static final String MONITORING_VERSION = "system_api_version";
|
||||
public static final String INTERVAL = "interval";
|
||||
|
||||
@Inject
|
||||
public RestMonitoringBulkAction(Settings settings, RestController controller) {
|
||||
|
@ -45,12 +45,17 @@ public class RestMonitoringBulkAction extends MonitoringRestHandler {
|
|||
String defaultType = request.param("type");
|
||||
|
||||
String id = request.param(MONITORING_ID);
|
||||
if (Strings.hasLength(id) == false) {
|
||||
throw new IllegalArgumentException("no monitoring id for monitoring bulk request");
|
||||
if (Strings.isEmpty(id)) {
|
||||
throw new IllegalArgumentException("no [" + MONITORING_ID + "] for monitoring bulk request");
|
||||
}
|
||||
String version = request.param(MONITORING_VERSION);
|
||||
if (Strings.hasLength(version) == false) {
|
||||
throw new IllegalArgumentException("no monitoring version for monitoring bulk request");
|
||||
if (Strings.isEmpty(version)) {
|
||||
throw new IllegalArgumentException("no [" + MONITORING_VERSION + "] for monitoring bulk request");
|
||||
}
|
||||
// we don't currently use the interval, but in future releases we can incorporate it without breaking BWC since it was here from
|
||||
// the beginning
|
||||
if (Strings.isEmpty(request.param(INTERVAL))) {
|
||||
throw new IllegalArgumentException("no [" + INTERVAL + "] for monitoring bulk request");
|
||||
}
|
||||
|
||||
if (!RestActions.hasBodyContent(request)) {
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
"system_api_version" : {
|
||||
"type" : "string",
|
||||
"description" : "API Version of the monitored system"
|
||||
},
|
||||
"interval": {
|
||||
"type" : "string",
|
||||
"description" : "Collection interval (e.g., '10s' or '10000ms') of the payload"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -17,8 +17,9 @@ setup:
|
|||
|
||||
- do:
|
||||
xpack.monitoring.bulk:
|
||||
system_id: "kibana"
|
||||
system_id: "kibana"
|
||||
system_api_version: "2"
|
||||
interval: "10s"
|
||||
body:
|
||||
- index:
|
||||
_type: test_type
|
||||
|
@ -51,8 +52,9 @@ setup:
|
|||
|
||||
- do:
|
||||
xpack.monitoring.bulk:
|
||||
system_id: "kibana"
|
||||
system_id: "kibana"
|
||||
system_api_version: "2"
|
||||
interval: "10000ms"
|
||||
type: "default_type"
|
||||
body:
|
||||
- '{"index": {}}'
|
||||
|
@ -89,3 +91,36 @@ setup:
|
|||
type: kibana
|
||||
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
# Missing a system_id causes it to fail
|
||||
- do:
|
||||
catch: request
|
||||
xpack.monitoring.bulk:
|
||||
system_api_version: "2"
|
||||
interval: "10s"
|
||||
type: "default_type"
|
||||
body:
|
||||
- '{"index": {}}'
|
||||
- '{"field_1": "value_1"}'
|
||||
|
||||
# Missing a system_api_version causes it to fail
|
||||
- do:
|
||||
catch: request
|
||||
xpack.monitoring.bulk:
|
||||
system_id: "kibana"
|
||||
interval: "10s"
|
||||
type: "default_type"
|
||||
body:
|
||||
- '{"index": {}}'
|
||||
- '{"field_1": "value_1"}'
|
||||
|
||||
# Missing an interval causes it to fail
|
||||
- do:
|
||||
catch: request
|
||||
xpack.monitoring.bulk:
|
||||
system_id: "kibana"
|
||||
system_api_version: "2"
|
||||
type: "default_type"
|
||||
body:
|
||||
- '{"index": {}}'
|
||||
- '{"field_1": "value_1"}'
|
||||
|
|
Loading…
Reference in New Issue