Skip to content

ES-10037 Configurable metrics in data stream auto-sharding #125612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,23 +278,12 @@ protected void masterOperation(
final IndexAbstraction indexAbstraction = projectMetadata.getIndicesLookup().get(resolvedRolloverTarget.resource());
if (indexAbstraction.getType().equals(IndexAbstraction.Type.DATA_STREAM)) {
DataStream dataStream = (DataStream) indexAbstraction;
final Optional<IndexStats> indexStats = Optional.ofNullable(statsResponse)
.map(stats -> stats.getIndex(dataStream.getWriteIndex().getName()));

Double indexWriteLoad = indexStats.map(
stats -> Arrays.stream(stats.getShards())
.filter(shardStats -> shardStats.getStats().indexing != null)
// only take primaries into account as in stateful the replicas also index data
.filter(shardStats -> shardStats.getShardRouting().primary())
.map(shardStats -> shardStats.getStats().indexing.getTotal().getWriteLoad())
.reduce(0.0, Double::sum)
).orElse(null);

rolloverAutoSharding = dataStreamAutoShardingService.calculate(projectState, dataStream, indexWriteLoad);
IndexStats indexStats = statsResponse != null ? statsResponse.getIndex(dataStream.getWriteIndex().getName()) : null;
rolloverAutoSharding = dataStreamAutoShardingService.calculate(projectState, dataStream, indexStats);
logger.debug("auto sharding result for data stream [{}] is [{}]", dataStream.getName(), rolloverAutoSharding);

// if auto sharding recommends increasing the number of shards we want to trigger a rollover even if there are no
// other "regular" conditions matching (we want to aggressively increse the number of shards) so we're adding the
// other "regular" conditions matching (we want to aggressively increase the number of shards) so we're adding the
// automatic {@link OptimalShardCountCondition} to the rollover request conditions so it gets evaluated and triggers
// the rollover operation (having this condition met will also provide a useful paper trail as it'll get stored in
// the {@link org.elasticsearch.action.admin.indices.rollover.RolloverInfo#metConditions} )
Expand Down
Loading