-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add write_load_forecast field to DataStreamsStats #92923
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
Conversation
|
@dakrone could you please review this PR? |
| return new DataStreamsStatsAction.DataStreamShardStats(indexShard.routingEntry(), storeStats, maxTimestamp); | ||
| var indexMetadata = indexService.getMetadata(); | ||
| assert indexMetadata != null; | ||
| double writeLoadForecast = writeLoadForecaster.getForecastedWriteLoad(indexMetadata).orElse(0.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not entirely sure if this usage of the WriteLoadForecaster is correct, can somebody verify that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage is ok except:
-
we should preserve
emptyrather than mapping it to 0. The difference between "write load is zero" and "write load is missing" is important. -
there's no need to do this for each shard. Instead we should extract the write load from the index metadata in
getResponseFactory. -
we only want the write load from the write index of the data stream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB edited^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @DaveCTurner for your feedback, I fixed the things you mentioned, writeLoadForecast is now Nullable and extracted only from the write index of the data stream
|
Pinging @elastic/es-data-management (Team:Data Management) |
DaveCTurner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @PhilKes, I left a few more comments. Also I don't think this will even pass ./gradlew precommit as it stands, make sure you run that and fix up the problems it raises.
| .index(indexAbstraction.getWriteIndex()) | ||
| .getForecastedWriteLoad(); | ||
| if (writeLoadForeCast.isPresent()) { | ||
| stats.writeLoadForecast = writeLoadForeCast.getAsDouble(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better, thanks! However, this is now just the load for one shard of the write index. I think we want to multiply this by the number of shards in that index too.
Actually I can see value in knowing both the per-shard and per-index numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I added the multiplication with getNumberOfShards().
Do you think I should add the per-shard write load too? Having writeLoadForecast and writeLoadForecastPerShard?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think I should add the per-shard write load too?
Yes please (let's make both of the names specific: ...PerShard and ...PerIndex)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think I should add the per-shard write load too?
Yes please (let's make both of the names specific:
...PerShardand...PerIndex)
Done
| if (indexAbstraction.getType() == IndexAbstraction.Type.DATA_STREAM) { | ||
| IndexAbstraction.DataStream dataStream = (IndexAbstraction.DataStream) indexAbstraction; | ||
| AggregatedStats stats = aggregatedDataStreamsStats.computeIfAbsent(dataStream.getName(), s -> new AggregatedStats()); | ||
| OptionalDouble writeLoadForeCast = clusterState.getMetadata() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
| OptionalDouble writeLoadForeCast = clusterState.getMetadata() | |
| OptionalDouble writeLoadForecast = clusterState.getMetadata() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed spelling error
| AggregatedStats stats = aggregatedDataStreamsStats.computeIfAbsent(dataStream.getName(), s -> new AggregatedStats()); | ||
| OptionalDouble writeLoadForeCast = clusterState.getMetadata() | ||
| .index(indexAbstraction.getWriteIndex()) | ||
| .getForecastedWriteLoad(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might this throw a NullPointerException sometimes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats true, getWriteIndex() can return null, I added a null-check, and also precommit told me to use WriteLoadForecaster to get the writeload instead of IndexMetadata.getForecastedWriteLoad().
DaveCTurner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks good to me. A few more non-implementation tasks needed:
-
I'd like there to be a test like the ones in
DataStreamsStatsTestswhere they aren'tnull(for which I think you will need to make a test-specific plugin which overridesClusterPlugin#createWriteLoadForecasters). -
These new fields need mentioning in
docs/reference/indices/data-stream-stats.asciidoc -
Similarly it would be good to have some mention of them in
modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/120_data_streams_stats.yml, just to say that they really do exist in the output (null is fine here).
Thank you @DaveCTurner, but I need some guidance on this. I added the fields to the I added the fields to the For the actual Test I tried to implement a new Test class EDIT: Ok I found out I can set the number of shards with the settings when creating the Template new Template(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, shards).build(),I guess I will simply add a Test case to the |
I'm ok not to mention this in the docs.
Yes that sounds right. |
…ssary notes in data-stream-stats.asciidoc
Ok so I added the |
# Conflicts: # modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DataStreamsStatsTransportAction.java # modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamsStatsTests.java
This PR Closes #91878 by adding the
write_load_forecastfield to theDataStreamsStatswhich is returned byGET /_data_streams/_stats