-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[ML] DF Analytics should always display operational stats #54210
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
Changes from 1 commit
ef956fb
c80c1d7
49a6d70
0b0478f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,10 +42,10 @@ | |||||||||||
| import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsState; | ||||||||||||
| import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsTaskState; | ||||||||||||
| import org.elasticsearch.xpack.core.ml.dataframe.stats.AnalysisStats; | ||||||||||||
| import org.elasticsearch.xpack.core.ml.dataframe.stats.common.DataCounts; | ||||||||||||
| import org.elasticsearch.xpack.core.ml.dataframe.stats.Fields; | ||||||||||||
| import org.elasticsearch.xpack.core.ml.dataframe.stats.MemoryUsage; | ||||||||||||
| import org.elasticsearch.xpack.core.ml.dataframe.stats.classification.ClassificationStats; | ||||||||||||
| import org.elasticsearch.xpack.core.ml.dataframe.stats.common.DataCounts; | ||||||||||||
| import org.elasticsearch.xpack.core.ml.dataframe.stats.outlierdetection.OutlierDetectionStats; | ||||||||||||
| import org.elasticsearch.xpack.core.ml.dataframe.stats.regression.RegressionStats; | ||||||||||||
| import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex; | ||||||||||||
|
|
@@ -60,7 +60,9 @@ | |||||||||||
| import java.util.ArrayList; | ||||||||||||
| import java.util.Collections; | ||||||||||||
| import java.util.Comparator; | ||||||||||||
| import java.util.HashMap; | ||||||||||||
| import java.util.List; | ||||||||||||
| import java.util.Map; | ||||||||||||
| import java.util.Set; | ||||||||||||
| import java.util.concurrent.atomic.AtomicInteger; | ||||||||||||
| import java.util.stream.Collectors; | ||||||||||||
|
|
@@ -140,9 +142,15 @@ protected void doExecute(Task task, GetDataFrameAnalyticsStatsAction.Request req | |||||||||||
| runningTasksStatsResponse -> gatherStatsForStoppedTasks(request.getExpandedIds(), runningTasksStatsResponse, | ||||||||||||
| ActionListener.wrap( | ||||||||||||
| finalResponse -> { | ||||||||||||
|
|
||||||||||||
| // We need to have access to the config itself to fill in missing defaults which | ||||||||||||
| // is why we do it here | ||||||||||||
| List<Stats> statsWithDefaults = buildStatsWithDefaults(getResponse.getResources().results(), | ||||||||||||
| finalResponse.getResponse().results()); | ||||||||||||
|
|
||||||||||||
| // While finalResponse has all the stats objects we need, we should report the count | ||||||||||||
| // from the get response | ||||||||||||
| QueryPage<Stats> finalStats = new QueryPage<>(finalResponse.getResponse().results(), | ||||||||||||
| QueryPage<Stats> finalStats = new QueryPage<>(statsWithDefaults, | ||||||||||||
| getResponse.getResources().count(), GetDataFrameAnalyticsAction.Response.RESULTS_FIELD); | ||||||||||||
| listener.onResponse(new GetDataFrameAnalyticsStatsAction.Response(finalStats)); | ||||||||||||
| }, | ||||||||||||
|
|
@@ -310,6 +318,31 @@ private GetDataFrameAnalyticsStatsAction.Response.Stats buildStats(String concre | |||||||||||
| ); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| private List<Stats> buildStatsWithDefaults(List<DataFrameAnalyticsConfig> configs, List<Stats> stats) { | ||||||||||||
| Map<String, DataFrameAnalyticsConfig> configById = new HashMap<>(); | ||||||||||||
| for (DataFrameAnalyticsConfig config : configs) { | ||||||||||||
| configById.put(config.getId(), config); | ||||||||||||
| } | ||||||||||||
|
||||||||||||
| Map<String, DataFrameAnalyticsConfig> configById = new HashMap<>(); | |
| for (DataFrameAnalyticsConfig config : configs) { | |
| configById.put(config.getId(), config); | |
| } | |
| Map<String, DataFrameAnalyticsConfig> configById = configs.stream().collect(Collectors.toMap(DataFrameAnalyticsConfig::getId, Function.identity())); |
Outdated
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.
Why can't this and the memory usage be initialized in the stats ctor?
this.memoryUsage = memoryUsage == null ? new MemoryUsage(config.getId(), Instant.now(), 0) : memoryUsage;
this.dataCounts = dataCounts == null ? new DataCounts(config.getId()) : dataCounts;
Why do we need to set memory_usage create time to the config's create time? Is that adding value for the added complexity?
Or maybe I am misunderstanding the Stats#getId() value...
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 agree that's too much complexity for the gain. I'll make MemoryUsage.timestamp nullable.
Uh oh!
There was an error while loading. Please reload this page.