[Monitoring] Stop Accepting .monitoring-data-N index requests via REST (elastic/x-pack-elasticsearch#1318)

Now that the Monitoring UI no longer checks the `.monitoring-data-2` index
for Kibana, Logstash, or Beats data, we can stop accepting the duplicated
data in that index (the _exact_ same documents are also indexed into the
time-based index for each product).

This ignores rather than rejects requests that contain such documents to
allow older clients to communicate with a 5.5+ monitoring cluster.

Original commit: elastic/x-pack-elasticsearch@def472cf2e
This commit is contained in:
Chris Earle 2017-05-05 11:53:43 -04:00 committed by GitHub
parent 5a4b7ee98b
commit 8ab46e800c
4 changed files with 28 additions and 11 deletions

View File

@ -94,13 +94,19 @@ public class MonitoringBulkRequest extends ActionRequest {
for (DocWriteRequest request : bulkRequest.requests()) {
if (request instanceof IndexRequest) {
IndexRequest indexRequest = (IndexRequest) request;
final IndexRequest indexRequest = (IndexRequest) request;
// we no longer accept non-timestamped indexes from Kibana, LS, or Beats because we do not use the data
// and it was duplicated anyway; by simply dropping it, we allow BWC for older clients that still send it
if (MonitoringIndex.from(indexRequest.index()) != MonitoringIndex.TIMESTAMPED) {
continue;
}
// builds a new monitoring document based on the index request
MonitoringBulkDoc doc =
new MonitoringBulkDoc(defaultMonitoringId,
defaultMonitoringApiVersion,
MonitoringIndex.from(indexRequest.index()),
MonitoringIndex.TIMESTAMPED,
indexRequest.type(),
indexRequest.id(),
indexRequest.source(),

View File

@ -114,6 +114,7 @@ public class MonitoringBulkRequestTests extends ESTestCase {
final MonitoringIndex[] indices = new MonitoringIndex[nbDocs];
final String[] types = new String[nbDocs];
final XContentType xContentType = XContentType.JSON;
int dataCount = 0;
int i;
try (BytesStreamOutput content = new BytesStreamOutput()) {
@ -123,8 +124,13 @@ public class MonitoringBulkRequestTests extends ESTestCase {
if (rarely()) {
indices[i] = MonitoringIndex.DATA;
builder.field("_index", "_data");
dataCount++;
} else {
indices[i] = MonitoringIndex.TIMESTAMPED;
if (rarely()) {
builder.field("_index", "");
}
}
if (randomBoolean()) {
types[i] = randomAlphaOfLength(5);
@ -143,17 +149,20 @@ public class MonitoringBulkRequestTests extends ESTestCase {
MonitoringBulkRequest request = new MonitoringBulkRequest();
request.add(content.bytes(), defaultMonitoringId, defaultMonitoringVersion, defaultType, xContentType);
assertThat(request.getDocs(), hasSize(nbDocs));
assertThat(request.getDocs(), hasSize(nbDocs - dataCount));
i = 0;
for (MonitoringBulkDoc doc : request.getDocs()) {
String expectedType = types[i] != null ? types[i] : defaultType;
for (final MonitoringBulkDoc doc : request.getDocs()) {
// we actively ignore IndexRequests for the _data index; this provides BWC to older versions
if (indices[i] != MonitoringIndex.DATA) {
final String expectedType = types[i] != null ? types[i] : defaultType;
assertThat(doc.getMonitoringId(), equalTo(defaultMonitoringId));
assertThat(doc.getMonitoringVersion(), equalTo(defaultMonitoringVersion));
assertThat(doc.getIndex(), sameInstance(indices[i]));
assertThat(doc.getType(), equalTo(expectedType));
assertThat(doc.getMonitoringId(), equalTo(defaultMonitoringId));
assertThat(doc.getMonitoringVersion(), equalTo(defaultMonitoringVersion));
assertThat(doc.getIndex(), sameInstance(MonitoringIndex.TIMESTAMPED));
assertThat(doc.getType(), equalTo(expectedType));
}
++i;
}

View File

@ -71,12 +71,13 @@
- match: { hits.total: 1 }
# We actively ignore indexing requests made to .monitoring-data-N starting with 5.5
- do:
search:
index: .monitoring-data-*
type: kibana
- match: { hits.total: 1 }
- match: { hits.total: 0 }
# Missing a system_id causes it to fail
- do:

View File

@ -107,11 +107,12 @@ teardown:
type: logstash_metric
- match: { hits.total: 1 }
# We actively ignore indexing requests made to .monitoring-data-N starting with 5.5
- do:
search:
index: .monitoring-data-*
type: logstash_info
- match: { hits.total: 1 }
- match: { hits.total: 0 }
- do:
catch: forbidden