Add configured indexing memory limit to node stats (#60414)

This commit adds the configured memory limit to the node stats API.
This commit is contained in:
Tim Brooks 2020-07-29 12:28:21 -06:00 committed by GitHub
parent 6054d33a63
commit 85fdf959ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 2 deletions

View File

@ -2227,6 +2227,15 @@ Number of indexing requests rejected in the primary stage.
(integer)
Number of indexing requests rejected in the replica stage.
========
`limit`::
(<<byte-units,byte value>>)
Configured memory limit for the indexing requests. Replica requests have an
automatic limit that is 1.5x this value.
`limit_in_bytes`::
(integer)
Configured memory limit, in bytes, for the indexing requests. Replica requests
have an automatic limit that is 1.5x this value.
=======
======

View File

@ -29,3 +29,20 @@
- gte: { nodes.$node_id.indexing_pressure.memory.total.coordinating_rejections: 0 }
- gte: { nodes.$node_id.indexing_pressure.memory.total.primary_rejections: 0 }
- gte: { nodes.$node_id.indexing_pressure.memory.total.replica_rejections: 0 }
---
"Indexing pressure memory limit":
- skip:
version: " - 7.9.99"
reason: "memory limit was added in 7.10"
features: [arbitrary_key]
- do:
nodes.info: {}
- set:
nodes._arbitrary_key_: node_id
- do:
nodes.stats:
metric: [ indexing_pressure ]
- gte: { nodes.$node_id.indexing_pressure.memory.limit_in_bytes: 0 }

View File

@ -146,6 +146,6 @@ public class IndexingPressure {
return new IndexingPressureStats(totalCombinedCoordinatingAndPrimaryBytes.get(), totalCoordinatingBytes.get(),
totalPrimaryBytes.get(), totalReplicaBytes.get(), currentCombinedCoordinatingAndPrimaryBytes.get(),
currentCoordinatingBytes.get(), currentPrimaryBytes.get(), currentReplicaBytes.get(), coordinatingRejections.get(),
primaryRejections.get(), replicaRejections.get());
primaryRejections.get(), replicaRejections.get(), primaryAndCoordinatingLimits);
}
}

View File

@ -19,6 +19,7 @@
package org.elasticsearch.index.stats;
import org.elasticsearch.Version;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
@ -43,6 +44,7 @@ public class IndexingPressureStats implements Writeable, ToXContentFragment {
private final long coordinatingRejections;
private final long primaryRejections;
private final long replicaRejections;
private final long memoryLimit;
public IndexingPressureStats(StreamInput in) throws IOException {
totalCombinedCoordinatingAndPrimaryBytes = in.readVLong();
@ -58,12 +60,18 @@ public class IndexingPressureStats implements Writeable, ToXContentFragment {
coordinatingRejections = in.readVLong();
primaryRejections = in.readVLong();
replicaRejections = in.readVLong();
if (in.getVersion().onOrAfter(Version.V_7_10_0)) {
memoryLimit = in.readVLong();
} else {
memoryLimit = -1L;
}
}
public IndexingPressureStats(long totalCombinedCoordinatingAndPrimaryBytes, long totalCoordinatingBytes, long totalPrimaryBytes,
long totalReplicaBytes, long currentCombinedCoordinatingAndPrimaryBytes, long currentCoordinatingBytes,
long currentPrimaryBytes, long currentReplicaBytes, long coordinatingRejections, long primaryRejections,
long replicaRejections) {
long replicaRejections, long memoryLimit) {
this.totalCombinedCoordinatingAndPrimaryBytes = totalCombinedCoordinatingAndPrimaryBytes;
this.totalCoordinatingBytes = totalCoordinatingBytes;
this.totalPrimaryBytes = totalPrimaryBytes;
@ -75,6 +83,7 @@ public class IndexingPressureStats implements Writeable, ToXContentFragment {
this.coordinatingRejections = coordinatingRejections;
this.primaryRejections = primaryRejections;
this.replicaRejections = replicaRejections;
this.memoryLimit = memoryLimit;
}
@Override
@ -92,6 +101,10 @@ public class IndexingPressureStats implements Writeable, ToXContentFragment {
out.writeVLong(coordinatingRejections);
out.writeVLong(primaryRejections);
out.writeVLong(replicaRejections);
if (out.getVersion().onOrAfter(Version.V_7_10_0)) {
out.writeVLong(memoryLimit);
}
}
public long getTotalCombinedCoordinatingAndPrimaryBytes() {
@ -151,6 +164,8 @@ public class IndexingPressureStats implements Writeable, ToXContentFragment {
private static final String COORDINATING_REJECTIONS = "coordinating_rejections";
private static final String PRIMARY_REJECTIONS = "primary_rejections";
private static final String REPLICA_REJECTIONS = "replica_rejections";
private static final String LIMIT = "limit";
private static final String LIMIT_IN_BYTES = "limit_in_bytes";
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
@ -173,6 +188,7 @@ public class IndexingPressureStats implements Writeable, ToXContentFragment {
builder.field(PRIMARY_REJECTIONS, primaryRejections);
builder.field(REPLICA_REJECTIONS, replicaRejections);
builder.endObject();
builder.humanReadableField(LIMIT_IN_BYTES, LIMIT, new ByteSizeValue(memoryLimit));
builder.endObject();
return builder.endObject();
}