-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Enable Shard-Level Search-load rate metric #128660
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
drempapis
merged 55 commits into
elastic:main
from
drempapis:search_load_per_index_multiproject
Jun 11, 2025
Merged
Changes from 10 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
e0b4e4b
Calculate search load per shard in multiproject env
drempapis 6d9b8bf
export package for transport action
drempapis 2d9b8b6
merge main
drempapis c058a33
update transport version
drempapis 254f739
Merge branch 'main' into search_load_per_index_multiproject
drempapis 6614cf9
update license headers
drempapis 20574d4
Merge branch 'search_load_per_index_multiproject' of github.com:dremp…
drempapis aa0c5b2
[CI] Auto commit changes from spotless
c8fb560
Register action name in constants
drempapis 062fb9f
Merge branch 'main' into search_load_per_index_multiproject
drempapis 182f3b6
update after review
drempapis 0c7bf62
Merge branch 'main' into search_load_per_index_multiproject
drempapis 102bdc1
Removing the allocationId
drempapis 31b63b0
[CI] Auto commit changes from spotless
76d1540
merge main and update after review
drempapis 695d57b
update after review
drempapis b276035
update after review
drempapis 6e73c2e
remove stale package from .info file
drempapis ebb6ed0
Merge branch 'main' into search_load_per_index_multiproject
drempapis 7cfec46
update after review
drempapis 2f3597b
Merge branch 'main' into search_load_per_index_multiproject
drempapis d7fab3b
merge main
drempapis 8f5ea6b
Merge branch 'main' into search_load_per_index_multiproject
drempapis 73d93a5
update after review
drempapis 8f36172
update after review
drempapis bf6ae86
merge main and resolve conflicts
drempapis 8b1f24d
add brief documentation for searchLoad
drempapis 7c16279
[CI] Auto commit changes from spotless
91ef808
Added yaml file for the search load / shard level
drempapis 02100c2
Merge branch 'search_load_per_index_multiproject' of github.com:dremp…
drempapis ca429e6
Merge branch 'main' into search_load_per_index_multiproject
drempapis 06145ee
Merge branch 'main' into search_load_per_index_multiproject
drempapis bd9c5ea
Merge branch 'main' into search_load_per_index_multiproject
drempapis 30ad337
update after review
drempapis c7b322a
Update server/src/main/java/org/elasticsearch/index/search/stats/Sear…
drempapis 877c62e
update after review
drempapis 6ced664
Merge branch 'search_load_per_index_multiproject' of github.com:dremp…
drempapis 011e654
[CI] Auto commit changes from spotless
17b5611
update after review
drempapis a43ae30
Merge branch 'search_load_per_index_multiproject' of github.com:dremp…
drempapis 56ce7b0
merge main to branch
drempapis 0a3ab4c
merge main
drempapis 7af8949
Merge branch 'main' into search_load_per_index_multiproject
drempapis 34d7b6d
Update after review
drempapis cb1088a
Merge branch 'search_load_per_index_multiproject' of github.com:dremp…
drempapis e4e82f7
[CI] Auto commit changes from spotless
5efd07a
Merge branch 'main' into search_load_per_index_multiproject
drempapis 7c0462e
Merge branch 'main' into search_load_per_index_multiproject
drempapis ccd37ba
Merge branch 'main' into search_load_per_index_multiproject
drempapis d5e2751
Merge branch 'main' into search_load_per_index_multiproject
drempapis eeb558d
Merge branch 'main' into search_load_per_index_multiproject
drempapis cb48991
Update for serverless checks
drempapis 5bb7b9e
Merge branch 'main' into search_load_per_index_multiproject
drempapis b439f89
Merge branch 'main' into search_load_per_index_multiproject
drempapis 8f30723
Merge branch 'main' into search_load_per_index_multiproject
drempapis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
server/src/main/java/org/elasticsearch/action/search/load/ShardSearchLoadStats.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.action.search.load; | ||
|
|
||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.common.io.stream.Writeable; | ||
| import org.elasticsearch.transport.Transports; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * ShardStats class represents the statistics of a shard in an index. | ||
drempapis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * It contains information such as the index name, shard ID, allocation ID, and EWMA rate. | ||
| */ | ||
| public class ShardSearchLoadStats implements Writeable { | ||
|
|
||
| private final String indexName; | ||
|
|
||
| private final Integer shardId; | ||
|
|
||
| private final String allocationId; | ||
drempapis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private final Double emwRate; | ||
drempapis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Constructor to create a ShardStats object from a StreamInput. | ||
| * | ||
| * @param in the StreamInput to read from | ||
| * @throws IOException if an I/O error occurs | ||
| */ | ||
| public ShardSearchLoadStats(StreamInput in) throws IOException { | ||
| assert Transports.assertNotTransportThread("O(#shards) work must always fork to an appropriate executor"); | ||
| this.indexName = in.readString(); | ||
| this.shardId = in.readVInt(); | ||
| this.allocationId = in.readString(); | ||
| this.emwRate = in.readDouble(); | ||
| } | ||
|
|
||
| /** | ||
| * Constructor to create a ShardStats object with the given parameters. | ||
| * | ||
| * @param indexName the name of the index | ||
| * @param shardId the ID of the shard | ||
| * @param allocationId the allocation ID of the shard | ||
| * @param ewma the EWMA rate of the shard | ||
| */ | ||
| public ShardSearchLoadStats(String indexName, Integer shardId, String allocationId, Double ewma) { | ||
| this.indexName = indexName; | ||
| this.shardId = shardId; | ||
| this.allocationId = allocationId; | ||
| this.emwRate = ewma; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| ShardSearchLoadStats that = (ShardSearchLoadStats) o; | ||
| return Objects.equals(indexName, that.indexName) | ||
| && Objects.equals(shardId, that.shardId) | ||
| && Objects.equals(allocationId, that.allocationId) | ||
| && Objects.equals(emwRate, that.emwRate); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(indexName, shardId, allocationId, emwRate); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the index name of the shard. | ||
| * | ||
| * @return the index name | ||
| */ | ||
| public String getIndexName() { | ||
| return this.indexName; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the shard ID of the shard. | ||
| * | ||
| * @return the shard ID | ||
| */ | ||
| public Integer getShardId() { | ||
| return this.shardId; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the allocation ID of the shard. | ||
| * | ||
| * @return the allocation ID | ||
| */ | ||
| public String getAllocationId() { | ||
| return this.allocationId; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the EWMA rate of the shard. | ||
| * | ||
| * @return the EWMA rate | ||
| */ | ||
| public Double getEwmRate() { | ||
| return this.emwRate; | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| out.writeString(indexName); | ||
| out.writeVInt(shardId); | ||
| out.writeString(allocationId); | ||
| out.writeDouble(emwRate); | ||
| } | ||
| } | ||
36 changes: 36 additions & 0 deletions
36
server/src/main/java/org/elasticsearch/action/search/load/ShardSearchLoadStatsAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.action.search.load; | ||
|
|
||
| import org.elasticsearch.action.ActionType; | ||
| import org.elasticsearch.action.RemoteClusterActionType; | ||
|
|
||
| /** | ||
| * Action definition for retrieving shard-level search load statistics. | ||
| * <p> | ||
| * This action serves as a marker for executing {@link TransportShardSearchLoadStatsAction} | ||
| * </p> | ||
| */ | ||
| public class ShardSearchLoadStatsAction extends ActionType<ShardSearchLoadStatsResponse> { | ||
drempapis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Singleton instance of the action type. | ||
| */ | ||
drempapis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public static final ShardSearchLoadStatsAction INSTANCE = new ShardSearchLoadStatsAction(); | ||
| public static final String NAME = "internal:search/stats"; | ||
drempapis marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public static final RemoteClusterActionType<ShardSearchLoadStatsResponse> REMOTE_TYPE = new RemoteClusterActionType<>( | ||
| NAME, | ||
| ShardSearchLoadStatsResponse::new | ||
| ); | ||
|
|
||
| private ShardSearchLoadStatsAction() { | ||
| super(NAME); | ||
| } | ||
| } | ||
81 changes: 81 additions & 0 deletions
81
server/src/main/java/org/elasticsearch/action/search/load/ShardSearchLoadStatsResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.action.search.load; | ||
|
|
||
| import org.elasticsearch.action.support.DefaultShardOperationFailedException; | ||
| import org.elasticsearch.action.support.broadcast.ChunkedBroadcastResponse; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.xcontent.ToXContent; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Iterator; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * Response to a shard stats request. | ||
| */ | ||
| public class ShardSearchLoadStatsResponse extends ChunkedBroadcastResponse { | ||
|
|
||
| private final ShardSearchLoadStats[] shards; | ||
|
|
||
| /** | ||
| * Constructor to create a ShardStatsResponse object from a StreamInput. | ||
| * | ||
| * @param in the StreamInput to read from | ||
| * @throws IOException if an I/O error occurs | ||
| */ | ||
| ShardSearchLoadStatsResponse(StreamInput in) throws IOException { | ||
| super(in); | ||
| shards = in.readArray(ShardSearchLoadStats::new, ShardSearchLoadStats[]::new); | ||
| } | ||
|
|
||
| /** | ||
| * Constructor to create a ShardStatsResponse object with the given parameters. | ||
| * | ||
| * @param shards the array of shard stats | ||
| * @param totalShards the total number of shards | ||
| * @param successfulShards the number of successful shards | ||
| * @param failedShards the number of failed shards | ||
| * @param shardFailures the list of shard failures | ||
| */ | ||
| ShardSearchLoadStatsResponse( | ||
| ShardSearchLoadStats[] shards, | ||
| int totalShards, | ||
| int successfulShards, | ||
| int failedShards, | ||
| List<DefaultShardOperationFailedException> shardFailures | ||
| ) { | ||
| super(totalShards, successfulShards, failedShards, shardFailures); | ||
| this.shards = shards; | ||
| Objects.requireNonNull(shards); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the array of shard stats. | ||
| * | ||
| * @return the array of shard stats | ||
| */ | ||
| public ShardSearchLoadStats[] getShards() { | ||
| return shards; | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| super.writeTo(out); | ||
| out.writeArray(shards); | ||
| } | ||
|
|
||
| @Override | ||
| protected Iterator<ToXContent> customXContentChunks(ToXContent.Params params) { | ||
| return null; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.